home *** CD-ROM | disk | FTP | other *** search
/ NOVA - For the NeXT Workstation / NOVA - For the NeXT Workstation.iso / Documents / FAQ / Compression / compression.faq < prev   
Text File  |  1992-12-27  |  95KB  |  2,100 lines

  1. -----Part 1 (part 2 appended)
  2. Archive-name: compression-faq/part1
  3. Last-modified: June 4th, 1992
  4.  
  5. [*** Short notice: see new question 9 about the WEB 16:1 compressor. ***]
  6.  
  7. This file is part 1 of a set of Frequently Asked Questions (FAQ) for the
  8. group comp.compression.  Certain questions get asked time and again,
  9. and this is an attempt to reduce the bandwidth taken up by these posts
  10. and their associated replies.  If you have a question, *please* check
  11. this file before you post.  It may save a lot of peoples time.
  12.  
  13. If you have not already read the overall Usenet introductory material
  14. posted to "news.announce.newusers", please do.
  15.  
  16. If you don't want to see this FAQ twice a month, please add the
  17. subject line to your kill file. If you have corrections or suggestions
  18. for this FAQ, send them to Jean-loup Gailly <jloup@chorus.fr>.
  19. Thank you.
  20.  
  21. Part 1 is oriented towards practical usage of compression programs.
  22. Part 2 is more intended for people who want to know how compression works.
  23.  
  24. Main changes relative to the previous version: 
  25.  
  26. - added arc, desea and zoo for Macintosh (question 2)
  27. - used binhex4.0.bin instead of stuffit-151.hqx to avoid chicken and egg
  28.   problem (question 2)
  29. - added question 9: "The WEB 16:1 compressor"
  30. - added the address of Iterated Systems (question 10)
  31. - added information from comp.dsp faq about audio compression (question 14)
  32. - added question 17: "I need source for arithmetic coding"
  33.  
  34. Contents
  35. ========
  36.  
  37. General questions:
  38.  
  39. [1]  What is this newsgroup about?
  40. [2]  What is this .xxx file type?
  41.      Where can I find the corresponding compression program?
  42. [3]  Where can I get image compression programs?
  43. [4]  What is an archiver?
  44. [5]  What is the best general purpose compression program?
  45. [6]  What is the state of the art in lossless image compression?
  46. [7]  Which books should I read?
  47. [8]  What about patents on data compression algorithms?
  48. [9]  The WEB 16:1 compressor.
  49. [10] What is the state of fractal compression?
  50. [11] What is the V.42bis standard?
  51. [12] I need specs and source for TIFF and CCITT group 4 Fax.
  52. [13] What is JPEG?
  53. [14] Are there algorithms and standards for audio compression?
  54. [15] I need source for the winners of the Dr Dobbs compression contest
  55. [16] I am looking for source of an H.261 codec.
  56. [17] I need source for arithmetic coding
  57.  
  58. Common problems:
  59.  
  60. [30] My archive is corrupted!
  61. [31] pkunzip reports a CRC error!
  62. [32] VMS zip is not compatible with pkzip!
  63.  
  64. Questions which do not really belong to comp.compression:
  65.  
  66. [50] What is this 'tar' compression program?
  67. [51] I need a CRC algorithm
  68. [52] What about those people who continue to ask frequently asked questions?
  69. [53] Where are FAQ lists archived?
  70. [54] I need specs for graphics formats
  71. [55] Where can I find Lenna and other images?
  72.  
  73. (Long) introductions to data compression techniques (in part 2)
  74.  
  75. [70] Introduction to data compression (long)
  76.        Huffman and Related Compression Techniques
  77.        Arithmetic Coding
  78.        Substitutional Compressors
  79.           The LZ78 family of compressors
  80.           The LZ77 family of compressors
  81.  
  82. [71] Introduction to MPEG (long)
  83.        What is MPEG?
  84.        Does it have anything to do with JPEG?
  85.        Then what's JBIG and MHEG?
  86.        What has MPEG accomplished?
  87.        So how does MPEG I work?
  88.        What about the audio compression?
  89.        So how much does it compress?
  90.        What's phase II?
  91.        When will all this be finished?
  92.        How do I join MPEG?
  93.        How do I get the documents, like the MPEG I draft?
  94.  
  95. [72] What is wavelet theory?
  96. [73] What is the theoretical compression limit?
  97. [74] Introduction to JBIG
  98.  
  99. [99] Acknowledgments
  100.  
  101. Search for "Subject: [#]" to get to question number # quickly. Some news
  102. readers can also take advantage of the message digest format used here.
  103.  
  104. If you know very little about data compression, read question 70 in
  105. part 2 first.
  106.  
  107. ------------------------------------------------------------------------------
  108.  
  109. ~Subject: [1] What is this newsgroup about?
  110.  
  111.  
  112. comp.compression is the place to discuss about data compression,
  113. both lossless (for text or data) and lossy (for images, sound, etc..).
  114.  
  115. If you only want to find a particular compression program for a
  116. particular operating system, please read first this FAQ and the
  117. article "How to find sources" which is regularly posted in
  118. news.answers.
  119.  
  120. If you can't resist posting, other groups are probably more appropriate
  121. (comp.binaries.ibm.pc.wanted, comp.sources.wanted, comp.sys.mac.wanted,
  122. alt.graphics.pixutils). Please post your request in comp.compression only
  123. as a last resource.
  124.  
  125. Please do not post any program in binary form to comp.compression.
  126. Very short sources can be posted, but long sources should be be posted
  127. to the specialized source groups, such as comp.sources.* or alt.sources.
  128.  
  129. ------------------------------------------------------------------------------
  130.  
  131. ~Subject: [2] What is this .xxx file type?
  132.              Where can I find the corresponding compression program?
  133.  
  134.  
  135. For most programs, one US and one European ftp site are given.
  136. (wuarchive.wustl.edu: 128.152.135.4, garbo.uwasa.fi: 128.214.87.1)
  137. Many other sites (in particular wsmr-simtel20.army.mil: 192.88.110.2)
  138. have the same programs.
  139.  
  140. To keep this list to a reasonable size, many programs are not
  141. mentioned here. Additional information can be found in the file
  142. ux1.cso.uiuc.edu:/doc/pcnet/compression [128.174.5.59] maintained by
  143. David Lemson (lemson@uiuc.edu). When several programs can handle
  144. the same archive format, only one of them is given.
  145.  
  146. For Macintosh programs, look on sumex-aim.stanford.edu:/info-mac [36.44.0.6].
  147. For VM/CMS, look on vmd.cso.uiuc.edu:/public.477 [128.174.5.98].
  148. For Atari, look on terminator.cc.umich.edu:/atari/archivers [141.211.164.8]
  149. For Amiga, look on ab20.larc.nasa.gov:/amiga/utils/archivers  [128.155.23.64]
  150.     
  151. If you don't know how to use ftp or don't have ftp access, read the
  152. article "How to find sources" which is regularly posted in news.answers.
  153.  
  154. If you can't find a program given below, it is likely that a newer
  155. version exists in the same directory. (Tell me <jloup@chorus.fr>)
  156.  
  157. ext:  produced by or read by
  158.  
  159. .arc: arc, pkarc (MSDOS)
  160.     wuarchive.wustl.edu:/mirrors/msdos/starter/pk361.exe
  161.     garbo.uwasa.fi:/pc/arcers/pk361.exe
  162.  
  163.       arc (Unix)
  164.         wuarchive.wustl.edu:/mirrors/misc/unix/arc521e.tar-z
  165.     garbo.uwasa.fi:/unix/arcers/arc.tar.Z
  166.         Contact: Howard Chu <hyc@umix.cc.umich.edu>
  167.  
  168.       arc (VMS)
  169.     wuarchive.wustl.edu:/packages/compression/vax-vms/arc.exe
  170.  
  171.       arcmac (Mac)
  172.     mac.archive.umich.edu:/mac/utilities/compressionapps/arcmac.hqx
  173.  
  174. .arj: arj (MSDOS)
  175.         wuarchive.wustl.edu:/mirrors/msdos/arc-lbr/arj230.exe
  176.     garbo.uwasa.fi:/pc/arcers/arj230ng.exe
  177.  
  178.       unarj (Unix). There is *no* arj for Unix. Don't post a request.
  179.         wuarchive.wustl.edu:/mirrors/misc/unix/unarj230.tar-z
  180.     garbo.uwasa.fi:/unix/arcers/unarj221.tar.Z
  181.       Contact: Robert K Jung <robjung@world.std.com>
  182.  
  183. .cpt: Compact Pro (Macintosh)
  184.         sumex-aim.stanford.edu:/info-mac/util/compact-pro-132.hqx [36.44.0.6]
  185.  
  186. .gif: gif files are images compressed with the LZW algorithm. See the
  187.       comp.graphics FAQ list for programs manipulating .gif files.
  188.  
  189. .hqx: Macintosh BinHex format
  190.        for Mac:
  191.      mac.archive.umich.edu:/mac/utilities/compressionapps/binhex4.0.bin
  192.  
  193.        for Unix:
  194.          sumex-aim.stanford.edu:/info-mac/unix/mcvert-165.shar [36.44.0.6]
  195.  
  196. .lzh: lha (MSDOS)
  197.     wuarchive.wustl.edu:/mirrors/msdos/arc-lbr/lha213.exe
  198.     garbo.uwasa.fi:/pc/arcers/lha213.exe
  199.  
  200.       lharc (Unix). Warning: lharc can extract .lzh files created by
  201.            lharc 1.xx but not those created by lha. See lha for Unix below.
  202.         wuarchive.wustl.edu:/mirrors/misc/unix/lharc102a.tar-z
  203.     garbo.uwasa.fi:/unix/arcers/lharcsrc.zoo
  204.  
  205.       lha (Unix) Warning: all doc is in Japanese.
  206.     garbo.uwasa.fi:/unix/arcers/lha-1.00.tar.Z
  207.         ftp.kuis.kyoto-u.ac.jp:/utils/lha-1.00.tar.Z
  208.           Contact: lha-admin@oki.co.jp
  209.  
  210.        lha (Mac)
  211.         (mac.archive.umich.edu:/mac/utilities/compressionapps/maclha2.0.cpt.hqx
  212.  
  213.       lharc (VMS). Same warning as for Unix lharc.
  214.     wuarchive.wustl.edu:/packages/compression/vax-vms/lharc.exe
  215.  
  216. .pak: pak (MSDOS)
  217.         wuarchive.wustl.edu:/mirrors/msdos/arc-lbr/pak251.exe
  218.     garbo.uwasa.fi:/pc/arcers/pak251.exe
  219.  
  220. .pit: PackIt (Macintosh)
  221.        for Mac:
  222.          sumex-aim.stanford.edu:/info-mac/util/stuffit-151.hqx  [36.44.0.6]
  223.  
  224.        for Unix:
  225.          sumex-aim.stanford.edu:/info-mac/unix/mcvert-165.shar [36.44.0.6]
  226.  
  227. .sea: self-extracting archive (Macintosh)
  228.          Run the file to extract it. You can also extract it with:
  229.       mac.archive.umich.edu:/mac/utilities/compressionapps/desea1.11.cpt.hqx
  230.  
  231. .sit: Stuffit (Macintosh)
  232.        for Mac:
  233.          sumex-aim.stanford.edu:/info-mac/util/stuffit-151.hqx [36.44.0.6]
  234.  
  235.        for Unix:
  236.          sumex-aim.stanford.edu:/info-mac/unix/unsit-15.shar [36.44.0.6]
  237.  
  238. .tar: tar is *not* a compression program. However, to be kind for you:
  239.       for MSDOS
  240.     wuarchive.wustl.edu:/mirrors/msdos/starter/tarread.exe
  241.     garbo.uwasa.fi:/pc/unix/tar4dos.zoo
  242.  
  243.       for Unix
  244.         tar (you have it already. To extract: tar xvf file.tar)
  245.  
  246.       for VMS
  247.     wuarchive.wustl.edu:/packages/compression/vax-vms/tar.exe
  248.  
  249.       for Macintosh
  250.         sumex-aim.stanford.edu:/info-mac/util/tar-30.hqx
  251.  
  252. .tar.Z, .tar-z, .taz: tar + compress
  253.       For Unix: zcat file.tar.Z | tar xvf -
  254.       Other OS: first uncompress (see .Z below) then untar (see .tar above)
  255.  
  256. .zip: pkzip 1.10 (MSDOS).
  257.          wuarchive.wustl.edu:/mirrors/msdos/zip/pkz110eu.exe.
  258.          garbo.uwasa.fi:/pc/arcers/pkz110eu.exe.
  259.            Note: pkz110eu.exe is an 'export' version without encryption.
  260.          ux1.cso.uiuc.edu:/pc/exec-pc/pkz193a.exe [128.174.5.59]
  261.            Note: pkzip 1.93a is an alpha version.
  262.            pkz201.exe is a hacked (illegal) copy of pkz193a.exe
  263.  
  264.       zip 1.0 and unzip 4.2 (Unix, MSDOS, VMS, OS/2)
  265.      wuarchive.wustl.edu:/mirrors/misc/unix/zip10ex.zip
  266.      wuarchive.wustl.edu:/mirrors/misc/unix/unzip42.tar-z
  267.          wuarchive.wustl.edu:/mirrors3/garbo.uwasa.fi/arcutil/zcrypt10.zip
  268.            Non US residents must get the encryption code from garbo (see below)
  269.      garbo.uwasa.fi:/unix/arcers/zip10ex.zip
  270.      garbo.uwasa.fi:/unix/arcers/unzip42.tar.Z.
  271.          garbo.uwasa.fi:/pc/arcutil/zcrypt10.zip  (encryption code)
  272.            Contact: zip-bugs@cs.ucla.edu
  273.  
  274.       zip 1.0 and unzip 4.2 (Mac)
  275.          valeria.cs.ucla.edu:/info-zip/Mac/zip_uzip.hqx
  276.          sumex-aim.stanford.edu:/info-mac/util/unzip-42.hqx
  277.  
  278. .zoo: zoo 2.10 (MSDOS)
  279.      wuarchive.wustl.edu:/mirrors/msdos/zoo/zoo210.exe
  280.      garbo.uwasa.fi:/pc/arcers/zoo210.exe
  281.  
  282.       zoo 2.10 (Unix, VMS)
  283.      wuarchive.wustl.edu:/mirrors/misc/unix/zoo210.tar-z
  284.      garbo.uwasa.fi:/unix/arcers/zoo210.tar.Z
  285.  
  286.       zoo (Mac)
  287.       mac.archive.umich.edu:/mac/utilities/compressionapps/maczoo.sit.hqx
  288.  
  289.       Contact: Rahul Dhesi <dhesi@cirrus.com>
  290.  
  291. .F: freeze (Unix)
  292.      wuarchive.wustl.edu:/usenet/comp.sources.misc/volume25/freeze/part0[1-2].Z
  293.      ftp.inria.fr:/system/arch-compr/freeze-2.3.2.tar.Z
  294.      Contact: Leonid A. Broukhis <leo@s514.ipmce.su>
  295.  
  296. .Y: yabba (Unix, VMS, ...)
  297.   wuarchive.wustl.edu:/usenet/comp.sources.unix/volume24/yabbawhap/part0[1-4].Z
  298.   ftp.inria.fr:/system/arch-compr/yabba.tar.Z
  299.   Contact: Dan Bernstein <brnstnd@nyu.edu>
  300.  
  301. .Z: compress (Unix)
  302.       It is likely that your Unix system has 'compress' already. Otherwise:
  303.     wuarchive.wustl.edu:/packages/compression/compress-4.1.tar
  304.         (not in .Z format to avoid chicken and egg problem)
  305.  
  306.     compress (MSDOS)
  307.     wuarchive.wustl.edu:/mirrors/msdos/compress/comp430[ds].zip
  308.     garbo.uwasa.fi:/pc/unix/comp430d.zip
  309.  
  310.     compress (Macintosh)
  311.         sumex-aim.stanford.edu:/info-mac/util/maccompress-32.hqx
  312.  
  313. ------------------------------------------------------------------------------
  314.  
  315. ~Subject: [3] Where can I get image compression programs?
  316.  
  317.  
  318. JPEG:
  319.       Source code for most any machine:
  320.       ftp.uu.net:/graphics/jpeg/jpegsrc.v3.tar.Z [137.39.1.9]
  321.       nic.funet.fi:/pub/graphics/programs/jpeg/jpegsrc.v3.tar.Z [128.214.6.100]
  322.       Contact: jpeg-info@uunet.uu.net (Independent JPEG Group)
  323.  
  324.       xv, an image viewer which can read JPEG pictures, is available in
  325.       ftp.cicb.fr:/pub/X11R5/contrib/xv-2.20.tar.Z  [129.20.128.2]
  326.  
  327. epic:
  328.       whitechapel.media.mit.edu:/pub/epic.tar.Z [18.85.0.125]
  329.       The "Lenna" test image is available as part of the EPIC package,
  330.       where it is named "test_image".
  331.  
  332. compfits:
  333.       uwila.cfht.hawaii.edu:/pub/compfits/compfits.tar.Z  [128.171.80.50]
  334.       Contact: Jim Wright <jwright@cfht.hawaii.edu>
  335.  
  336. fitspress:
  337.       128.103.40.79:/pub/fitspress08.tar.Z
  338.  
  339. tiff:
  340.       For source and sample images, see question 12 below.
  341.  
  342. ------------------------------------------------------------------------------
  343.  
  344. ~Subject: [4] What is an archiver?
  345.  
  346.  
  347. There is a distinction between archivers and other compression
  348. programs:
  349.  
  350. - an archiver takes several input files, compresses them and produces
  351.   a single archive file. Examples are arc, arj, lha, zip, zoo.
  352.  
  353. - other compression programs create one compressed file for each
  354.   input file. Examples are freeze, yabba, compress. Such programs
  355.   are often combined with tar to create compressed archives (see
  356.   question 50: "What is this tar compression program?").
  357.  
  358. ------------------------------------------------------------------------------
  359.  
  360. ~Subject: [5] What is the best general purpose compression program?
  361.  
  362.  
  363. The answer is: it depends. (You did not expect a definitive answer,
  364. did you?)
  365.  
  366. It depends whether you favor speed, compression ratio, a standard and
  367. widely used archive format, the number of features, etc...  Just as
  368. for text editors, personal taste plays an important role. compress has
  369. 4 options, arj 2.30 has about 130 options; different people like
  370. different programs. *Please* do not start or continue flame wars on
  371. such matters of taste.
  372.  
  373. The only objective comparisons are speed and compression ratio. Here
  374. is a short table comparing various programs on a 33Mhz Compaq 386.
  375. All programs have been run on Unix SVR4, except pkzip and arj which
  376. only run on MSDOS.  Detailed benchmarks have been posted in
  377. comp.compression by Peter Gutmann <pgut1@cs.aukuni.ac.nz>.
  378.  
  379. *Please* do not post your own benchmarks made on your own files that
  380. nobody else can access. If you think that you must absolutely post yet
  381. another benchmark, make sure that your test files are available by
  382. anonymous ftp.
  383.  
  384. The programs compared here were chosen because they are the most popular
  385. or because they run on Unix and source is available.  For ftp
  386. information, see above. Two programs (hpack and comp-2) have been added
  387. because they achieve better compression (at the expense of speed)
  388. and one program (lzrw3-a) has been added because it favors speed at
  389. the expense of compression:
  390. - comp-2 is in wuarchive.wustl.edu:/mirrors/msdos/ddjmag/ddj9102.zip
  391.   (inner zip file nelson.zip),
  392. - hpack is in wuarchive.wustl.edu:/mirrors/misc/unix/hpack75a.tar-z
  393.   and garbo.uwasa.fi:/unix/arcers/hpack75a.tar.Z
  394. - sirius.ucs.adelaide.edu.au:/pub/compression/lzrw3-a.c  [129.127.40.3]
  395.  
  396. The 14 files used in the comparison are from the standard Calgary
  397. Text Compression Corpus, available in
  398.   fsa.cpsc.ucalgary.ca:/pub/text.compression.corpus.tar.Z [136.159.2.1]
  399.  
  400. The whole corpus includes 18 files, but the 4 files paper[3-6] are
  401. generally omitted in benchmarks. It contains several kinds of file
  402. (ascii, binary, image, etc...) but has a bias towards large files.
  403. You may well get different ratings on the typical mix of files that
  404. you use daily, so keep in mind that the comparisons given below are
  405. only indicative.
  406.  
  407. The programs are ordered by decreasing total compressed size. For a
  408. fair comparison between archivers and other programs, this size is
  409. only the size of the compressed data, not the archive size.
  410.  
  411. The programs were run on an idle machine, so the elapsed time
  412. is significant and can be used to compare Unix and MSDOS programs.
  413.  
  414. [Note: I still have to add all decompression times.]
  415.  
  416.        size     lzrw3a   compress    lharc    yabba     pkzip    freeze 
  417. version:                   4.0       1.02      1.0       1.10     2.3.2 
  418. options:                                    -m300000                    
  419.        ------    -----    ------    ------    ------    ------   ------
  420. bib    111261    49040     46528     46502     40456     41354    41515 
  421. book1  768771   416131    332056    369479    306813    350560   344793 
  422. book2  610856   274371    250759    252540    229851    232589   230861 
  423. geo    102400    84214     77777     70955     76695     76172    68626 
  424. news   377109   191291    182121    166048    168287    157326   155783 
  425. obj1    21504    12647     14048     10748     13859     10546    10453 
  426. obj2   246814   108040    128659     90848    114323     90130    85500 
  427. paper1  53161    24522     25077     21748     22453     20041    20021 
  428. paper2  82199    39479     36161     35275     32733     32867    32693 
  429. pic    513216   111000     62215     61394     65377     63805    53291 
  430. progc   39611    17919     19143     15399     17064     14164    14143 
  431. progl   71646    24358     27148     18760     23512     17255    17064 
  432. progp   49379    16801     19209     12792     16617     11877    11686 
  433. trans   93695    30292     38240     28092     31300     23135    22861 
  434.     3,141,622  1,400,105 1,259,141 1,200,580 1,159,340 1,141,821 1,109,290
  435. real             0m35s     0m59s     5m03s     2m40s              5m09s
  436. user             0m25s     0m29s     4m29s     1m46s              4m04s
  437. sys              0m05s     0m10s     0m07s     0m18s              0m11s
  438. MSDOS:                                                   1m39s
  439.                         
  440.     zip      zoo       lha       arj      pkzip     hpack    comp-2   
  441.         1.0     2.10   0.04 & 2.13  2.30      1.93a     0.75a       
  442.      -9      ah                 -jm       -ex               
  443.        ------  ------     ------       ------    ------    ------   ------
  444. bib    40717   40742      40740        36090     35186     35619    29840  
  445. book1  339932  339076     339074       318382    313566    306876   237380  
  446. book2  229419  228444     228442       210521    207204    208486   174085  
  447. geo    69837   68576      68574        69209     68698     58976    64590  
  448. news   154865  155086     155084       146855    144954    141608   128047  
  449. obj1    10522   10312      10310        10333     10307     10572    10819  
  450. obj2    86661   84983      84981        82052     81213     80806    85465  
  451. paper1    19761   19678      19676        18710     18519     18607    16895  
  452. paper2    32296   32098      32096        30034     29566     29825    25453  
  453. pic    56828   52223      52221        53578     52777     51778    55461  
  454. progc    13955   13943      13941        13408     13363     13475    12896  
  455. progl    16954   16916      16914        16408     16148     16586    17354  
  456. progp    11558   11509      11507        11308     11214     11647    11668  
  457. trans    22737   22580      22578        20046     19808     20506    21023  
  458.     1,106,013 1,096,166 1,096,138 1,036,934 1,022,523 1,005,367  890,976
  459. real    3m28s   4m07s     6m03s                       1h22m17s  27m05s
  460. user    1m45s   3m47s      4m23s                    1h20m46s  19m27s
  461. sys     0m11s   0m04s      0m08s                       0m12s   2m03s
  462. MSDOS:                    1m49s     2m41s     1m55s
  463.  
  464. Notes:
  465. - zip 2.0 is not included in this comparison since it will be released
  466.   only when pkzip 2.0 is released. (Compression is comparable to that of
  467.   pkzip 1.93a.)
  468.  
  469. - the compressed data for 'zoo ah' is always two bytes longer than for
  470.   lha. This is simply because both programs are derived from the same
  471.   source (ar002, written by Haruhiko Okumura).
  472.  
  473. - hpack 0.75a gives slightly different results on SunOS (undeterministic
  474.   behaviour still under investigation).
  475.  
  476. - the MSDOS versions are all optimized with assembler code and were run
  477.   on a RAM disk. So it is not surprising that they go faster than their
  478.   Unix equivalent.
  479.  
  480. ------------------------------------------------------------------------------
  481.  
  482. ~Subject: [6] What is the state of the art in lossless image compression?
  483.  
  484.  
  485. The current state-of-the-art is the JBIG algorithm.  For an
  486. introduction to JBIG, see question 54 in part 2.
  487.  
  488. JBIG works best on bi-level images (like faxes) and also works well on
  489. Gray-coded grey scale images up to about six or so bits per pixel.  You
  490. just apply JBIG to the bit planes individually.  For more bits/pixel,
  491. lossless JPEG provides better performance, sometimes. (For JPEG, see
  492. question 13 below.)
  493.  
  494. You can find a description of JBIG in ISO/IEC CD 11544, contained in
  495. document ISO/IEC JTC1/SC2/N2285.  The only way to get it is to ask
  496. your National Standards Body for a copy.
  497.  
  498. ------------------------------------------------------------------------------
  499.  
  500. ~Subject: [7] Which books should I read?
  501.  
  502.  
  503.  
  504. [BWC 1989] Bell, T.C, Witten, I.H, and Cleary, J.G.  "Text Compression",
  505.     Prentice-Hall 1989. ISBN: 0-13-911991-4. Price: approx. US$40
  506.     The reference on text data compression.
  507.  
  508. [Nel 1991] Mark Nelson, "The Data Compression Book"
  509.     M&T Books, Redwood City, CA, 1991.  ISBN 1-55851-216-0.
  510.     Price $36.95 including two 5" PC-compatible disks bearing
  511.     all the source code printed in the book.
  512.     A practical introduction to data compression.
  513.     The book is targeted at a person who is comfortable reading C code but
  514.     doesn't know anything about data compression.  Its stated goal is to get
  515.     you up to the point where you are competent to program standard
  516.     compression algorithms.
  517.  
  518. [Will 1990] Williams, R.  "Adaptive Data Compression", Kluwer Books, 1990.
  519.     ISBN: 0-7923-9085-7. Price: US$75.
  520.     Reviews the field of text data compression and then addresses the
  521.     problem of compressing rapidly changing data streams.
  522.  
  523. [Stor 1988] Storer, J.A.  "Data Compression: Methods and Theory", Computer
  524.     Science Press, Rockville, MD. ISBN: 0-88175-161-8.
  525.     A survey of various compression techniques, mainly statistical
  526.     non-arithmetic compression and LZSS compression.  Includes complete Pascal
  527.     code for a series of LZ78 variants.
  528.  
  529. Review papers:
  530.  
  531. [BWC 1989] Bell, T.C, Witten, I.H, and Cleary, J.G.  "Modeling for Text
  532.     Compression", ACM Computing Surveys, Vol.21, No.4 (December 1989), p.557
  533.     A good general overview of compression techniques (as well as modeling for
  534.     text compression); the condensed version of "Text Compression".
  535.  
  536. [Lele 1987] Lelewer, D.A, and Hirschberg, D.S.  "Data Compression", ACM
  537.     Computing Surveys, Vol.19, No.3 (September 1987), p.261.
  538.     A survey of data compression techniques which concentrates on Huffman
  539.     compression and makes only passing mention of other techniques.
  540.  
  541.  
  542. ------------------------------------------------------------------------------
  543.  
  544. ~Subject: [8] What about patents on data compression algorithms?
  545.  
  546.  
  547. [Note: the appropriate group for discussing software patents is
  548. comp.patents (or misc.legal.computing), not comp.compression.]
  549.  
  550. - The Gibson & Graybill patent 5,049,881 is the most general.
  551.   Claims 4 and 12 cover about any LZ algorithm using hashing, and could
  552.   even be interpreted as applying to the LZ78 family. (See below,
  553.   "Introduction to data compression" for the meaning of 'LZ').
  554.  
  555.      4. A compression method for compressing a stream of input data into
  556.      a compressed stream of output data based on a minimum number of
  557.      characters in each input data string to be compressed, said
  558.      compression method comprising the creation of a hash table, hashing
  559.      each occurrence of a string of input data and subsequently searching
  560.      for identical strings of input data and if such an identical string
  561.      of input data is located whose string size is at least equal to the
  562.      minimum compression size selected, compressing the second and all
  563.      subsequent occurrences of such identical string of data, if a string
  564.      of data is located which does not match to a previously compressed
  565.      string of data, storing such data as uncompressed data, and for each
  566.      input strings after each hash is used to find a possible previous
  567.      match location of the string, the location of the string is stored
  568.      in the hash table, thereby using the previously processed data to
  569.      act as a compression dictionary.
  570.  
  571.   Claim 12 is identical, with 'method' replaced with 'apparatus'.
  572.   Since the 'minimal compression size' can be as small as 2, the claim
  573.   covers any dictionary technique of the LZ family.
  574.  
  575. - Phil Katz, author of pkzip, also has a patent on LZ77 (5,051,745)
  576.   but the claims only apply to sorted hash tables, and when the hash
  577.   table is substantially smaller than the window size.
  578.  
  579. - The LZW algorithm used in 'compress' is patented by IBM (4,814,746)
  580.   and Unisys (4,558,302). Unisys has licensed it for use in the V.42bis
  581.   compression standard. (See question 11 on V.42bis below.)
  582.  
  583. - AP coding is patented by Storer (4,876,541). (Get the yabba package
  584.   for source code, see question 2 above, file type .Y)
  585.  
  586. - Fiala and Greene have a patent (pending?) on the algorithms they
  587.   published in Comm.ACM, April 89. One of their algorithms is used in lha
  588.   and zoo, and was used in zip 0.8.
  589.  
  590. - IBM patented (5,001,478) the idea of combining a history buffer (the
  591.   LZ77 technique) and a lexicon (as in LZ78).
  592.  
  593. - IBM holds a patent on the Q-coder implementation of arithmetic
  594.   coding.  The arithmetic coding option of the JPEG standard requires
  595.   use of the patented algorithm. (See the JPEG FAQ for details.)
  596.  
  597.  
  598. Here are some references on data compression patents, taken from the
  599. list maintained by Michael Ernst <mernst@theory.lcs.mit.edu> in
  600. mintaka.lcs.mit.edu:/mitlpf/ai/patent-list (or patent-list.Z).
  601.  
  602. 4,464,650
  603. Apparatus and method for compressing data signals and restoring the
  604. compressed data signals
  605. inventors Lempel, Ziv, Cohn, Eastman
  606. assignees Sperry Corporation and At&T Bell Laboratories
  607. filed 8/10/81, granted 8/7/84
  608.  
  609. 4,558,302
  610. High speed data compression and decompression apparatus and method
  611. inventor Welch
  612. assignee Sperry Corporation (now Unisys)
  613. filed 6/20/83, granted 12/10/85
  614. The text for this patent can be ftped from ftp.uu.net as pub/lzw-patent.Z
  615.  
  616. 4,814,746
  617. Data compression method
  618. inventors Victor S. Miller, Mark N. Wegman
  619. assignee IBM
  620. filed 8/11/86, granted 3/21/89
  621.  
  622. 4,876,541
  623. Stem [sic] for dynamically compressing and decompressing electronic data
  624. inventor James A. Storer
  625. assignee Data Compression Corporation
  626. filed 10/15/87, granted 10/24/89
  627.  
  628. 4,955,066
  629. Compressing and Decompressing Text Files
  630. inventor Notenboom, L.A.
  631. assignee Microsoft
  632. filed  10/13/89, granted 09/04/90
  633.  
  634. 5,001,478
  635. Method of Encoding Compressed Data
  636. filed 1989-12-28
  637. granted 1991-03-19
  638. inventor Michael E. Nagy
  639. assignee IBM
  640.  
  641. 5,049,881
  642. Apparatus and method for very high data rate-compression incorporating
  643. lossless data compression and expansion utilizing a hashing technique
  644. inventors Dean K. Gibson, Mark D. Graybill
  645. assignee Intersecting Concepts, Inc.
  646. filed 6/18/90, granted 9/17/91
  647. cites McIntosh 3,914,586, Johannesson 4,087,788, Eastman 4,464,650,
  648.       Finn 4,560,976, Tsukiyama 4,586,027 and 4,758,899, Kunishi 4,677,649,
  649.       Mathes 4,682,150
  650.  
  651. 5,051,745
  652. String searcher, and compressor using same
  653. inventor  Phillip W. Katz (author of pkzip)
  654. filed  8/21/90, granted 9/24/91
  655. cites MacCrisken 4,730,348 and Hong 4,961,139
  656.  
  657. Data Compression with Finite Windows, Comm.ACM, 32,4 (1989) 490-595.
  658. inventors Fiala,E.R., and Greene,D.H.
  659.  
  660. ------------------------------------------------------------------------------
  661.  
  662. [9]  The WEB 16:1 compressor.
  663.  
  664.  
  665. [WARNING: this topic has generated the greatest volume of news in the
  666. history of comp.compression. Read this before posting on this subject.]
  667.  
  668.  
  669. (a) What the press says
  670.  
  671. April 20, 1992  Byte Week Vol 4. No. 25:
  672.  
  673.    "In an announcement that has generated high interest - and more than a
  674.    bit of skepticism - WEB Technologies (Smyrna, GA) says it has
  675.    developed a utility that will compress files of greater than 64KB in
  676.    size to about 1/16th their original length.  Furthermore, WEB says its
  677.    DataFiles/16 program can shrink files it has already compressed."
  678.    [...]
  679.    "A week after our preliminary test, WEB showed us the program successfully
  680.    compressing a file without losing any data.  But we have not been able
  681.    to test this latest beta release ourselves."
  682.    [...]
  683.    "WEB, in fact, says that virtually any amount of data can be squeezed 
  684.    to under 1024 bytes by using DataFiles/16 to compress its own output
  685.    multiple times."
  686.  
  687.  
  688. (b) First details, by John Wallace <buckeye@spf.trw.com>:
  689.  
  690. I called WEB at (404)514-8000 and they sent me some product
  691. literature as well as chatting for a few minutes with me on the phone.
  692. Their product is called DataFiles/16, and their claims for it are
  693. roughly those heard on the net.
  694.  
  695. According to their flier:
  696.  
  697. "DataFiles/16 will compress all types of binary files to approximately
  698. one-sixteenth of their original size ... regardless of the type of
  699. file (word processing document, spreadsheet file, image file,
  700. executable file, etc.), NO DATA WILL BE LOST by DataFiles/16."
  701. (Their capitalizations; 16:1 compression only promised for files >64K
  702. bytes in length.)
  703.  
  704. "Performed on a 386/25 machine, the program can complete a
  705. compression/decompression cycle on one megabyte of data in less than
  706. thirty seconds"
  707.  
  708. "The compressed output file created by DataFiles/16 can be used as the 
  709. input file to subsequent executions of the program.  This feature of 
  710. the utility is known as recursive or iterative compression, and will 
  711. enable you to compress your data files to a tiny fraction of the 
  712. original size.  In fact, virtually any amount of computer data can 
  713. be compressed to under 1024 bytes using DataFiles/16 to compress its 
  714. own output files muliple times.  Then, by repeating in reverse the 
  715. steps taken to perform the recusive compression, all original data 
  716. can be decompressed to its original form without the loss of a single 
  717. bit."
  718.  
  719. They had a table that showed the expected size of resulting files,
  720. with the warning that "Your actual compresion results may vary
  721. slightly from the figures shown".  Here is my abridged version of their
  722. table. 
  723.         ---------- Iteration -------
  724. INPUT        1    2    3     4        Ratio
  725. 1K        630                    1.6:1
  726. 16K        1.5K    812                20:1
  727. 64K        4K    1K    644            101:1
  728. 512K        30K    2K    938            558:1
  729. 8M        490K    14K    1.5K    798        10512:1
  730. 64M        3M    40K    3K    994        67513:1
  731.  
  732. Their flier also claims: 
  733.  
  734. "Constant levels of compression across ALL TYPES of FILES"
  735. "Convenient, single floppy DATA TRANSPORTATION"
  736.  
  737. From my telephone conversation, I was was assured that this is an
  738. actual compression program.  Decompression is done by using only the 
  739. data in the compressed file; there are no hidden or extra files.
  740.  
  741.  
  742. (c) More information, by Rafael Ramirez <rafael.ramirez@channel1.com>:
  743.  
  744.    Today (Tuesday, 28th) I got a call from Earl Bradley of Web
  745. who now says that they have put off releasing a software version of
  746. the algorithm because they are close to signing a major contract with
  747. a big company to put the algorithm in silicon.  He said he could not
  748. name the company due to non-disclosure agreements, but that they had
  749. run extensive independent tests of their own and verified that the
  750. algorithm works. [...]
  751.  
  752.    Mr. Bradley went on to say that Web will not be sending out any
  753. more copies to magazines and that they had even recalled the copy they
  754. had sent to Byte.  He claimed that he told the guy at Byte that the
  755. version they had at the time had just been translated to assembler and
  756. had some bugs, but that the guy at Byte kept insisting that they send
  757. a copy anyway, and so of course the version Byte had didn't work.
  758. He said the algorithm is so simple that he doesn't want anybody
  759. getting their hands on it and copying it even though he said they
  760. have filed a patent on it. [...] Mr. Bradley said the silicon version
  761. would hold up much better to patent enforcement and be harder to copy.
  762.  
  763.    He claimed that the algorithm takes up about 4K of code, uses only
  764. integer math, and the current software implementation only uses a 65K
  765. buffer.  He said the silicon version would likely use a parallel
  766. version and work in real-time.
  767.  
  768.    He said they will be sending out copies to about seven companies
  769. that want to license the technology for various applications but he
  770. could not give out any names due to non-disclosure agreements.  He
  771. hoped that in about two weeks he will be able to make an announcement
  772. and said he would call me when he could provide independent
  773. verification that the algorithm works.  For now, we can only wait.
  774.  
  775.    He also said they have not as yet sold anything, but that he's
  776. been traveling constantly for the last three weeks (presumably to
  777. the seven companies he mentioned) and that he hasn't slept very
  778. well lately just thinking about all the applications the algorithm
  779. could be applied to.
  780.  
  781.    And he confirmed that each pass will get 16:1 compression as
  782. long as the data is >64K, and that regardless, any file should be
  783. able to be compressed to less than 1024 bytes after enough passes.
  784. I asked if he is claiming that they can compress ANY data including
  785. data that is already compressed, and he just answered by saying
  786. that they had tested the program by compressing PKZIP files, and
  787. other files and that they all compressed as claimed (which of course
  788. still doesn't answer the question).
  789.  
  790.  
  791. (d) The interpretation of the claims
  792.  
  793. The biggest controversy is over the claim to compress "all types of
  794. files".  As noted above by Rafael Ramirez, we do not know with
  795. certainty if WEB claims to compress *all* files greater than 64K
  796. bytes, or just *most* files. The WEB flier only says all *types* of
  797. files, not *all* files.  Keep this in mind when reading the
  798. impossibility proof given below.
  799.  
  800.  
  801. (e) The impossiblity proofs.
  802.  
  803. It is impossible for a given program to compress without loss *all*
  804. files greater than a certain size by at least one bit. This can be
  805. proven by a simple counting argument. (Many other proofs have been
  806. posted on comp.compression, *please* do not post yet another one.)
  807.  
  808. Assume that the program can compress without loss all files of size >= N
  809. bits.  Compress with this program all the 2^N files which have
  810. exactly N bits.  All compressed files have at most N-1 bits, so there
  811. are at most 2^(N-1) different compressed files. So at least two
  812. different input files must compress to the same output file. (Actually
  813. at least half of them, but two suffice for the proof.) Hence the
  814. compression program cannot be lossless.
  815.  
  816. This argument applies of course to WEB's case (take N = 64K*8 bits).
  817. Note that no assumption is made about the compression algorithm.
  818. The proof applies to *any* algorithm, including those using an
  819. external dictionary, or repeated application of another algorithm,
  820. or combination of different algorithms, or representation of the
  821. data as formulas, etc... All schemes are subject to the counting argument.
  822. There is no need to use information theory to provide a proof, just
  823. basic mathematics.
  824.  
  825. This assumes of course that the information available to the decompressor
  826. is only the bit sequence of the compressed data. If external information
  827. such as a file name or a number of iterations is necessary to decompress
  828. the data, the bits providing the extra information must be included in
  829. the bit count of the compressed data. (Otherwise, it would be sufficient
  830. to consider any input data as a number, use this as the iteration
  831. count or file name, and pretend that the compressed size is zero.)
  832.  
  833.  
  834. (d) Conclusion
  835.  
  836. Most readers of comp.compression are tired of this thread.  Please,
  837. please, do not post another article "I know this has been beaten to
  838. death, but...".
  839.  
  840. The consensus is that we have to wait until WEB delivers a real product
  841. which can be independently tested. Only then will it be possible
  842. to know exactly what the product can and cannot do.
  843.  
  844. [See also question 73 "What is the theoretical compression limit?" in
  845. part 2 of this FAQ.]
  846.  
  847. ------------------------------------------------------------------------------
  848.  
  849. ~Subject: [10] What is the state of fractal compression?
  850.  
  851.  
  852. from Tal Kubo <kubo@zariski.harvard.edu>:
  853.  
  854. According to Barnsley's book 'Fractals Everywhere', this method is
  855. based on a measure of deviation between a given image and its
  856. approximation by an IFS code.  The Collage Theorem states that there is
  857. a convergent process to minimize this deviation.  Unfortunately,
  858. according to an article Barnsley wrote for BYTE a few years ago, this
  859. convergence was rather slow, about 100 hours on a Cray, unless assisted by
  860. a person.
  861.  
  862. Barnsley et al are not divulging any technical information beyond the
  863. meager bit in 'Fractals Everywhere'.  The book explains the idea of IFS
  864. codes at length, but is vague about the application of the Collage theorem
  865. to specific compression problems.
  866.  
  867. There is reason to believe that Barnsley's company has
  868. *no algorithm* which takes a given reasonable image and achieves
  869. the compression ratios initially claimed for their fractal methods.
  870. The 1000-to-1 compression advertised was achieved only for a 'rigged'
  871. class of images, with human assistance. The best unaided
  872. performance I've heard of is good lossy compression of about 80-1.
  873.  
  874. Steve Tate <srt@duke.cs.duke.edu> confirms:
  875.  
  876. Compression ratios (unzoomed) seem to range from 20:1 to 60:1...  The
  877. quality is considerably worse than wavelets or JPEG on most of the
  878. non-contrived images I have seen.
  879.  
  880.  
  881. There is a fractal image compression demo program  available via anonymous
  882. ftp in lyapunov.ucsd.edu:/pub/fractal_image_processing/all.tar.Z.
  883. There are executables and sample images in the same directory.
  884.  
  885. ~References:
  886.   M. Barnsley, L. Anson, "Graphics Compression Technology, SunWorld,
  887.     October 1991, pp. 42-52.
  888.   M.F. Barnsley, A. Jacquin, F. Malassenet, L. Reuter & A.D. Sloan,
  889.     'Harnessing chaos for image synthesis', Computer Graphics,
  890.     vol 22 no 4 pp 131-140, 1988.
  891.   M.F. Barnsley, A.E. Jacquin, 'Application of recurrent iterated
  892.     function systems to images', Visual Comm. and Image Processing,
  893.     vol SPIE-1001, 1988.
  894.   A. Jacquin, "Image Coding Based on a Fractal Theory of Iterated Contractive
  895.     Image Transformations" p.18, January 1992 (Vol 1 Issue 1) of IEEE Trans
  896.     on Image Processing.
  897.   A. Jacquin, A Fractal Theory of Iterated Markov Operators with
  898.     Applications to Digital Image Coding, PhD Thesis, Georgia Tech, 1989.
  899.   A.E. Jacquin, 'A novel fractal block-coding technique for digital
  900.     images', Proc. ICASSP 1990.
  901.   A. Jacquin, 'Fractal image coding based on a theory of iterated
  902.     contractive image transformations', Visual Comm. and Image
  903.     Processing, vol SPIE-1360, 1990.
  904.   G.E. Oien, S. Lepsoy & T.A. Ramstad, 'An inner product space
  905.     approach to image coding by contractive transformations',
  906.     Proc. ICASSP 1991, pp 2773-2776.
  907.   D.S. Mazel, Fractal Modeling of Time-Series Data, PhD Thesis,
  908.     Georgia Tech, 1991.    (One dimensional, not pictures)
  909.   S. A. Hollatz, "Digital image compression with two-dimensional affine
  910.     fractal interpolation functions", Department of Mathematics and
  911.     Statistics, University of Minnesota-Duluth, Technical Report 91-2.
  912.     (a nuts-and-bolts how-to-do-it paper on the technique)
  913.   Stark, J., ``Iterated function systems as neural networks'',
  914.     Neural Networks, Vol 4, pp 679-690, Pergamon Press, 1991.
  915.  
  916.  
  917. Barnsley's company is:
  918.  
  919. Iterated Systems Inc.               Contacts:  Alan Sloan
  920. 5550 Peachtree Parkway                         Rick Darby
  921. Norcross                                    or Louisa Anson (technical)
  922. Atlanta, Georgia
  923. GA 30092
  924.  
  925. Tel: 404-840-0633
  926. Fax: 404-840-0806
  927.  
  928. ------------------------------------------------------------------------------
  929.  
  930. ~Subject: [11] What is the V.42bis standard?
  931.  
  932.  
  933. from Alejo Hausner <hausner@qucis.queensu.ca>:
  934.  
  935. The V.42bis Compression Standard was proposed by the International
  936. Consultative Committee on Telephony and Telegraphy (CCITT) as an
  937. addition to the v.42 error-correction protocol for modems. Its purpose
  938. is to increase data throughput, and uses a variant of the
  939. Lempel-Ziv-Welch (LZW) compression method.  It is meant to be
  940. implemented in the modem hardware, but can also be built into the
  941. software that interfaces to an ordinary non-compressing modem.
  942.  
  943. V.42bis can send data compressed or not, depending on the
  944. data.  There are some types of data that cannot be
  945. compressed.  For example, if a file was compressed first,
  946. and then sent through a V.42bis modem, the modem would not
  947. likely reduce the number of bits sent.  Indeed it is likely
  948. that the amount of data would increase somewhat.
  949.  
  950. To avoid this problem, the algorithm constantly monitors the
  951. compressibility of the data, and if it finds fewer bits
  952. would be necessary to send it uncompressed, it switches to
  953. transparent mode.  The sender informs the receiver of this
  954. transition through a reserved escape code.  Henceforth the
  955. data is passed as plain bytes.
  956.  
  957. The choice of escape code is clever.  Initially, it is a
  958. zero byte.  Any occurrence of the escape code is replaced,
  959. as is customary, by two escape codes.  In order to prevent a
  960. string of escape codes from temporarily cutting throughput
  961. in half, the escape code is redefined by adding 51 mod 255
  962. each time it is used.
  963.  
  964. While transmitting in transparent mode, the sender maintains
  965. the LZW trees of strings, and expects the receiver to do
  966. likewise.  If it finds an advantage in returning to
  967. compressed mode, it will do so, first informing the receiver
  968. by a special control code.  Thus the method allows the
  969. hardware to adapt to the compressibility of the data.
  970.  
  971.  
  972. The CCITT standards documents are available by ftp on ftp.uu.net
  973. in directory /doc/standards/ccitt. Also on src.doc.ic.ac.uk,
  974. in directory doc/ccitt-standards/ccitt. The v42bis standard is in
  975. /doc/ccitt-standards/ccitt/1992/v/v42bis.asc.Z.
  976.  
  977. ------------------------------------------------------------------------------
  978.  
  979. ~Subject: [12] I need specs and source for TIFF and CCITT group 4 Fax
  980.  
  981.  
  982. Specs for Group 3 and 4 image coding (group 3 is very similar to group 4)
  983. are in CCITT (1988) volume VII fascicle VII.3. They are recommendations
  984. T.4 and T.6 respectively. There is also an updated spec contained in 1992
  985. recommendations T.1 to T.6.
  986.  
  987. CCITT specs are available by anonymous ftp (see above answer on V.42bis).
  988. The T.4 spec is in ccitt/1988/ascii/7_3_01.txt.Z, the T.6 spec
  989. is in 7_3_02.txt.Z.
  990.  
  991. Source code can be obtained as part of a TIFF toolkit - TIFF image
  992. compression techniques for binary images include CCITT T.4 and T.6:
  993.  
  994.     sgi.com:/graphics/tiff/v3.0beta.tar.Z     [192.48.153.1]
  995.     Contact: sam@sgi.com
  996.  
  997. There is also a companion compressed tar file (v3.0pics.tar.Z) that
  998. has sample TIFF image files. A draft of TIFF 6.0 is in TIFF6.ps.Z.
  999.  
  1000. See also question 54 below.
  1001.  
  1002. ------------------------------------------------------------------------------
  1003.  
  1004. ~Subject: [13] What is JPEG?
  1005.  
  1006.  
  1007. JPEG (pronounced "jay-peg") is a standardized image compression mechanism.
  1008. JPEG stands for Joint Photographic Experts Group, the original name of the
  1009. committee that wrote the standard.  JPEG is designed for compressing either
  1010. full-color or gray-scale digital images of "natural" (real-world) scenes.
  1011. JPEG does not handle black-and-white (1-bit-per-pixel) images, nor does it
  1012. handle motion picture compression.  (Standards for compressing those types
  1013. of images are being worked on by other committees, named JBIG and MPEG
  1014. respectively.)
  1015.  
  1016. A good introduction to JPEG is posted regularly in news.answers by
  1017. Tom Lane <tgl+@cs.cmu.edu>. (See question 53 "Where are FAQ lists archived"
  1018. if this posting has expired at your site.)
  1019.  
  1020. ------------------------------------------------------------------------------
  1021.  
  1022. ~Subject: [14] Are there algorithms and standards for audio compression?
  1023.  
  1024.  
  1025. Yes. See the introduction to MPEG given in part 2 of this FAQ.
  1026.  
  1027. Copied from the comp.dsp FAQ posted by guido@cwi.nl (Guido van Rossum):
  1028.  
  1029. Strange though it seems, audio data is remarkably hard to compress
  1030. effectively.  For 8-bit data, a Huffman encoding of the deltas between
  1031. successive samples is relatively successful.  For 16-bit data,
  1032. companies like Sony and Philips have spent millions to develop
  1033. proprietary schemes.
  1034.  
  1035. Public standards for voice compression are slowly gaining popularity,
  1036. e.g. CCITT G.721 and G.723 (ADPCM at 32 and 24 kbits/sec).  (ADPCM ==
  1037. Adaptive Delta Pulse Code Modulation.)
  1038.  
  1039. There are also two US federal standards, 1016 (Code excited linear
  1040. prediction (CELP), 4800 bits/s) and 1015 (LPC-10E, 2400 bits/s).  See
  1041. also the appendix for 1016.
  1042.  
  1043. (Note that U-LAW and silence detection can also be considered
  1044. compression schemes.)
  1045.  
  1046. ------------------------------------------------------------------------------
  1047.  
  1048. ~Subject: [15] I need source for the winners of the Dr Dobbs compression contest
  1049.  
  1050.  
  1051. The source of the top 6 programs of the Feb 91 Dr Dobbs data compression
  1052. contest are available by ftp on
  1053.   wsmr-simtel20.army.mil in pd1:<msdos.compress>ddjcompr.zip. [192.88.110.2]
  1054.   garbo.uwasa.fi:/pc/source/ddjcompr.zip [128.214.87.1]
  1055.  
  1056. The sources are in MSDOS end-of-line format, one directory per program.
  1057. Unix or VMS users, use "unzip -ad ddjcompr" to get correct end-of-lines
  1058. and recreate the directory structure. Five of the 6 programs are not
  1059. portable and only run on MSDOS.
  1060.  
  1061. ------------------------------------------------------------------------------
  1062.  
  1063. ~Subject: [16] I am looking for source of an H.261 codec.
  1064.  
  1065. from Thierry TURLETTI <turletti@sophia.inria.fr>:
  1066.  
  1067. We have implemented a software version of H.261 codec. 
  1068. It runs on top of UNIX and X-Windows. The coder uses the simple video capture
  1069. board "VideoPix" provided by SUN for the SparcStation. The output is directed
  1070. towards a standard TCP connection, instead of the leased lines or switched 
  1071. circuits for which regular H.261 codecs are designed. This enable us to test
  1072. video conferences over regular internet connections.
  1073. We have to polish it a bit, but the first release is now available by anonymous
  1074. ftp from avahi.inria.fr, in "/pub/h261.tar.Z".
  1075.  
  1076. ------------------------------------------------------------------------------
  1077.  
  1078. ~Subject: [17] I need source for arithmetic coding
  1079.  
  1080.  
  1081. (See question 70 for an introduction to arithmetic coding.)
  1082.  
  1083. Kris Popat <popat@image.mit.edu> has worked on "Scalar Quantization
  1084. with Arithmetic Coding."  It describes an arithmetic coding technique
  1085. which is quite general and computationally inexpensive.  The
  1086. documentation and example C code are available via anonymous ftp from
  1087. media-lab.media.mit.edu (18.85.0.2), in /pub/k-arith-code.
  1088.  
  1089. ------------------------------------------------------------------------------
  1090.  
  1091. ~Subject: [30] My archive is corrupted!
  1092.  
  1093.  
  1094. The two most common reasons for this are
  1095.  
  1096. (1) failing to use the magic word "tenex" (when connected to SIMTEL20 and
  1097.     other TOPS20 systems) or "binary" (when connected to UNIX systems) when
  1098.     transferring the file from an ftp site to your host machine.  The
  1099.     reasons for this are technical and boring.  A synonym for "tenex" is
  1100.     "type L 8", in case your ftp doesn't know what "tenex" means.
  1101.  
  1102. (2) failing to use an eight-bit binary transfer protocol when transferring
  1103.     the file from the host to your PC.  Make sure to set the transfer type
  1104.     to "binary" on both your host machine and your PC.
  1105.  
  1106. ------------------------------------------------------------------------------
  1107.  
  1108. ~Subject: [31] pkunzip reports a CRC error!
  1109.  
  1110.  
  1111. The portable zip contains many workarounds for undocumented restrictions
  1112. in pkunzip. Compatibility is ensured for pkunzip 1.10 only. All previous
  1113. versions (pkunzip 1.0x) have too many bugs and cannot be supported. This
  1114. includes Borland unzip.
  1115.  
  1116. So if your pkunzip reports a CRC error, check that you are not using
  1117. an obsolete version. Get either pkzip 1.10 or unzip 4.2 (see question
  1118. 2 above for ftp sites).
  1119.  
  1120. Immediately after zip 1.0 was released, a new undocumented feature
  1121. of pkunzip was discovered, which causes CRC errors even with pkunzip 1.10
  1122. on rare occasions. A patch is available on valeria.cs.ucla.edu in
  1123. /pub/zip10.patch.
  1124.  
  1125. ------------------------------------------------------------------------------
  1126.  
  1127. ~Subject: [32] VMS zip is not compatible with pkzip!
  1128.  
  1129.  
  1130. The problem is most likely in the file transfer program.
  1131.  
  1132. Many use kermit to transfer zipped files between PC and VMS VAX.  The
  1133. following VMS kermit settings make VMS-ZIP compatible with PKZIP:
  1134.  
  1135.                                              VMS kermit        PC kermit
  1136.                                            ---------------   --------------
  1137.  
  1138. Uploading PKZIPped file to be UNZIPped:    set fi ty fixed    set fi ty bi
  1139. Downloading ZIPped file to be PKUNZIPped:  set fi ty block    set fi ty bi
  1140.  
  1141. If you are not using kermit, transfer a file created by pkzip on MSDOS
  1142. to VMS, transfer it back to your PC and check that pkunzip can extract it.
  1143.  
  1144. ------------------------------------------------------------------------------
  1145.  
  1146. ~Subject: [50] What is this 'tar' compression program?
  1147.  
  1148.  
  1149. tar is not a compression program. It just combines several files
  1150. into one, without compressing them. tar file are often compressed with
  1151. 'compress', resulting in a .tar.Z file. See question 2, file type .tar.Z.
  1152. (However, some versions of tar have the capability to compress files
  1153. as well.)
  1154.  
  1155. When you have to archive a lot of very small files, it is often
  1156. preferable to create a single .tar file and compress it, than to
  1157. compress the individual files separately. The compression program can
  1158. thus take advantage of redundancy between separate files.  The
  1159. disadvantage is that you must uncompress the whole .tar file to
  1160. extract any member.
  1161.  
  1162. ------------------------------------------------------------------------------
  1163.  
  1164. ~Subject: [51] I need a CRC algorithm
  1165.  
  1166.  
  1167. As its name implies (Cyclic Redundancy Check) a crc adds redundancy
  1168. whereas the topic of this group is to remove it. But since this
  1169. question comes up often, here is some code (by Rob Warnock <rpw3@sgi.com>).
  1170.  
  1171. The following C code does CRC-32 in BigEndian/BigEndian byte/bit order.
  1172. That is, the data is sent most significant byte first, and each of the bits
  1173. within a byte is sent most significant bit first, as in FDDI. You will need
  1174. to twiddle with it to do Ethernet CRC, i.e., BigEndian/LittleEndian byte/bit
  1175. order. [Left as an exercise for the reader.]
  1176.  
  1177. The CRCs this code generates agree with the vendor-supplied Verilog models
  1178. of several of the popular FDDI "MAC" chips.
  1179.  
  1180. u_long crc32_table[256];
  1181. /* Initialized first time "crc32()" is called. If you prefer, you can
  1182.  * statically initialize it at compile time. [Another exercise.]
  1183.  */
  1184.  
  1185. u_long crc32(u_char *buf, int len)
  1186. {
  1187.         u_char *p;
  1188.         u_long  crc;
  1189.  
  1190.         if (!crc32_table[1])    /* if not already done, */
  1191.                 init_crc32();   /* build table */
  1192.         crc = 0xffffffff;       /* preload shift register, per CRC-32 spec */
  1193.         for (p = buf; len > 0; ++p, --len)
  1194.                 crc = (crc << 8) ^ crc32_table[(crc >> 24) ^ *p];
  1195.         return ~crc;            /* transmit complement, per CRC-32 spec */
  1196. }
  1197.  
  1198. /*
  1199.  * Build auxiliary table for parallel byte-at-a-time CRC-32.
  1200.  */
  1201. #define CRC32_POLY 0x04c11db7     /* AUTODIN II, Ethernet, & FDDI */
  1202.  
  1203. init_crc32()
  1204. {
  1205.         int i, j;
  1206.         u_long c;
  1207.  
  1208.         for (i = 0; i < 256; ++i) {
  1209.                 for (c = i << 24, j = 8; j > 0; --j)
  1210.                         c = c & 0x80000000 ? (c << 1) ^ CRC32_POLY : (c << 1);
  1211.                 crc32_table[i] = c;
  1212.         }
  1213. }
  1214.  
  1215. ------------------------------------------------------------------------------
  1216.  
  1217. ~Subject: [52] What about those people who continue to ask frequently asked
  1218.               questions in spite of the frequently asked questions document?
  1219.  
  1220.  
  1221. Just send them a polite mail message, referring them to this document.
  1222. There is no need to flame them on comp.compression.  That would just
  1223. add more noise to this group.  Posted answers that are in the FAQ are
  1224. just as annoying as posted questions that are in the FAQ.
  1225.  
  1226. ------------------------------------------------------------------------------
  1227.  
  1228. ~Subject: [53] Where are FAQ lists archived?
  1229.  
  1230.  
  1231. Many are crossposted to news.answers.  That newsgroup should have a
  1232. long expiry time at your site; if not, talk to your sysadmin.
  1233.  
  1234. FAQ lists are available by anonymous FTP from pit-manager.mit.edu
  1235. (18.72.1.58) and by email from mail-server@pit-manager.mit.edu (send
  1236. a message containing "help" for instructions about the mail server).
  1237.  
  1238. This posting is /pub/usenet/news.answers/compression-faq/part1.
  1239. Part 2 is in (guess?) compression-faq/part2.
  1240.  
  1241. ------------------------------------------------------------------------------
  1242.  
  1243. ~Subject: [54] I need specs for graphics formats
  1244.  
  1245.  
  1246. Have a look in directory public/graphics.formats on titan.rice.edu.
  1247. It contains descriptions of gif, tiff, fits, etc...
  1248.  
  1249. See also the FAQ list for comp.graphics.
  1250.  
  1251. ------------------------------------------------------------------------------
  1252.  
  1253. ~Subject: [55] Where can I find Lenna and other images?
  1254.  
  1255.  
  1256. A bunch of standard images (lenna, baboon, cameraman, crowd, moon
  1257. etc..)  were on ftp site gauss.eedsp.gatech.edu (130.207.226.2) in
  1258. directory /database/images. On Apr 1st, the system manager said:
  1259. this site has had some hardware problems and will have the image
  1260. database back online as soon as the problems get corrected. However
  1261. the images are still not there (June 4th).
  1262.  
  1263. The site ftp.ipl.rpi.edu also has standard images, in two directories:
  1264.    ftp.ipl.rpi.edu:/pub/image/still/usc 
  1265.    ftp.ipl.rpi.edu:/pub/image/still/canon
  1266.  
  1267. In each of those directories are the following directories:
  1268.    bgr     - 24 bit blue, green, red
  1269.    color   - 24 bit red, green, blue
  1270.    gray    - 8 bit grayscale uniform weighted
  1271.    gray601 - 8 bit grayscale CCIR-601 weighted
  1272.  
  1273. And in these directories are the actual images.  
  1274.  
  1275. For example, the popular lena image is in
  1276.    ftp.ipl.rpi.edu:/pub/image/still/usc/color/lena  # 24 bit RGB
  1277.    ftp.ipl.rpi.edu:/pub/image/still/usc/bgr/lena    # 24 bit BGR
  1278.    ftp.ipl.rpi.edu:/pub/image/still/usc/gray/lena   # 8 bit gray
  1279.  
  1280. All of the images are in Sun rasterfile format.  You can use the pbm
  1281. utilities to convert them to whatever format is most convenient.
  1282. [pbm is available in ftp.ee.lbl.gov:/pbmplus*.tar.Z].
  1283. Questions about the ipl archive should be sent to rodney@ipl.rpi.edu.
  1284.  
  1285. The archive maintainer at ftp.ipl.rpi.edu is interested in some method
  1286. of establishing a canonical ftp database of images and could volunteer
  1287. the ipl to be an ftp site for that database. Send suggestions to
  1288. rodney@ipl.rpi.edu.
  1289.  
  1290.  
  1291. Beware: the same image often comes in many different forms, at
  1292. different resolutions, etc... The original lenna image is 512 wide,
  1293. 512 high, 8 bits per pel, red, green and blue fields.  Gray-scale
  1294. versions of Lenna have been obtained in two different ways from the
  1295. original:
  1296.  (1) Using the green field as a gray-scale image, and
  1297.  (2) Doing an RGB->YUV transformation and saving the Y component.
  1298. Method (1) makes it easier to compare different people's results since
  1299. everyone's version should be the same using that method.  Method (2)
  1300. produces a more correct image.
  1301.  
  1302. For the curious: 'lena' or 'lenna' is a digitized Playboy centerfold,
  1303. from November 1972. (Lenna is the spelling in Playboy, Lena is the
  1304. Swedish spelling of the name.) Lena Soderberg (ne Sjooblom) was last
  1305. reported living in her native Sweden, happily married with three kids
  1306. and a job with the state liquor monopoly.  In 1988, she was
  1307. interviewed by some Swedish computer related publication, and she was
  1308. pleasantly amused by what had happened to her picture.  That was the
  1309. first she knew of the use of that picture in the computer business.
  1310.  
  1311. The editorial in the January 1992 issue of Optical Engineering (v. 31
  1312. no. 1) details how Playboy has finally caught on to the fact that
  1313. their copyright on Lenna Sjooblom's photo is being widely infringed.
  1314. It sounds as if you will have to get permission from Playboy to
  1315. publish it in the future.
  1316.  
  1317. ----Part 2
  1318. Contents
  1319. ========
  1320.  
  1321. (Long) introductions to data compression techniques
  1322.  
  1323. [70] Introduction to data compression (long)
  1324.        Huffman and Related Compression Techniques
  1325.        Arithmetic Coding
  1326.        Substitutional Compressors
  1327.           The LZ78 family of compressors
  1328.           The LZ77 family of compressors
  1329.  
  1330. [71] Introduction to MPEG (long)
  1331.        What is MPEG?
  1332.        Does it have anything to do with JPEG?
  1333.        Then what's JBIG and MHEG?
  1334.        What has MPEG accomplished?
  1335.        So how does MPEG I work?
  1336.        What about the audio compression?
  1337.        So how much does it compress?
  1338.        What's phase II?
  1339.        When will all this be finished?
  1340.        How do I join MPEG?
  1341.        How do I get the documents, like the MPEG I draft?
  1342.  
  1343. [72] What is wavelet theory?
  1344. [73] What is the theoretical compression limit?
  1345. [74] Introduction to JBIG
  1346.  
  1347. [99] Acknowledgments
  1348.  
  1349. Search for "Subject: [#]" to get to question number # quickly. Some news
  1350. readers can also take advantage of the message digest format used here.
  1351.  
  1352. ------------------------------------------------------------------------------
  1353.  
  1354. ~Subject: [70] Introduction to data compression (long)
  1355.  
  1356.  
  1357. Written by Peter Gutmann <pgut1@cs.aukuni.ac.nz>.
  1358.  
  1359.  Huffman and Related Compression Techniques
  1360.  ------------------------------------------
  1361.  
  1362.   *Huffman compression* is a statistical data compression technique which 
  1363. gives a reduction in the average code length used to represent the symbols of 
  1364. a alphabet.  The Huffman code is an example of a code which is optimal in the 
  1365. case where all symbols probabilities are integral powers of 1/2.  A Huffman 
  1366. code can be built in the following manner:
  1367.  
  1368.   (1) Rank all symbols in order of probability of occurrence.
  1369.     
  1370.   (2) Successively combine the two symbols of the lowest probability to form
  1371.       a new composite symbol; eventually we will build a binary tree where
  1372.       each node is the probability of all nodes beneath it.
  1373.  
  1374.   (3) Trace a path to each leaf, noticing the direction at each node.
  1375.  
  1376.   For a given frequency distribution, there are many possible Huffman codes,
  1377. but the total compressed length will be the same. It is possible to
  1378. define a 'canonical' Huffman tree, that is, pick one of these alternative
  1379. trees. Such a canonical tree can then be represented very compactly, by
  1380. transmitting only the bit length of each code. This technique is used
  1381. in most archivers (pkzip, lha, zoo, arj, ...).
  1382.  
  1383.  
  1384.   A technique related to Huffman coding is *Shannon-Fano coding*, which was 
  1385. suggested by Shannon and Weaver in 1949 and modified by Fano in 1961.  It 
  1386. works as follows:
  1387.  
  1388.   (1} Rank all symbols in order of probability of occurrence.
  1389.     
  1390.   (2) Successively divide the set of symbols into two equal or almost equal
  1391.       subsets based on the probability of occurrence of characters in each 
  1392.       subset.  The first symbol in one subset is assigned a binary zero, the
  1393.       second a binary one.
  1394.     
  1395. The algorithm used to create the Huffman codes is bottom-up, and the
  1396. one for the Shannon-Fano codes is top-down. Huffman encoding always
  1397. generates optimal codes, Shannon-Fano sometimes uses a few more bits.
  1398.  
  1399.  
  1400.  Arithmetic Coding
  1401.  -----------------
  1402.  
  1403.   It would appear that Huffman or Shannon-Fano coding is the perfect
  1404. means of compressing data.  However, this is *not* the case.  As
  1405. mentioned above, these coding methods are optimal when and only when
  1406. the symbol probabilities are integral powers of 1/2, which is usually
  1407. not the case.
  1408.  
  1409.   The technique of *arithmetic coding* does not have this restriction:
  1410. It achieves the same effect as treating the message as one single unit
  1411. (a technique which would, for Huffman coding, require enumeration of
  1412. every single possible message), and thus attains the theoretical
  1413. entropy bound to compression efficiency for any source.
  1414.  
  1415.   Arithmetic coding works by representing a number by an interval of real 
  1416. numbers between 0 and 1.  As the message becomes longer, the interval needed 
  1417. to represent it becomes smaller and smaller, and the number of bits needed to 
  1418. specify that interval increases.  Successive symbols in the message reduce 
  1419. this interval in accordance with the probability of that symbol. The more
  1420. likely symbols reduce the range by less, and thus add fewer bits to the   
  1421. message.
  1422.  
  1423.      1                                             Codewords
  1424.     +-----------+-----------+-----------+           /-----\
  1425.     |           |8/9 YY     |  Detail   |<- 31/32    .11111
  1426.     |           +-----------+-----------+<- 15/16    .1111
  1427.     |    Y      |           | too small |<- 14/16    .1110
  1428.     |2/3        |    YX     | for text  |<- 6/8      .110
  1429.     +-----------+-----------+-----------+
  1430.     |           |           |16/27 XYY  |<- 10/16    .1010
  1431.     |           |           +-----------+
  1432.     |           |    XY     |           |
  1433.     |           |           |   XYX     |<- 4/8      .100
  1434.     |           |4/9        |           |
  1435.     |           +-----------+-----------+
  1436.     |           |           |           |
  1437.     |    X      |           |   XXY     |<- 3/8      .011
  1438.     |           |           |8/27       |
  1439.     |           |           +-----------+
  1440.     |           |    XX     |           |
  1441.     |           |           |           |<- 1/4      .01
  1442.     |           |           |   XXX     |
  1443.     |           |           |           |
  1444.     |0          |           |           |
  1445.     +-----------+-----------+-----------+
  1446.  
  1447.   As an example of arithmetic coding, lets consider the example of two
  1448. symbols X and Y, of probabilities 0.66 and 0.33. To encode this message, we
  1449. examine the first symbol: If it is a X, we choose the lower partition; if
  1450. it is a Y, we choose the upper partition.  Continuing in this manner for
  1451. three symbols, we get the codewords shown to the right of the diagram above
  1452. - they can be found by simply taking an appropriate location in the
  1453. interval for that particular set of symbols and turning it into a binary
  1454. fraction. In practice, it is also necessary to add a special end-of-data
  1455. symbol, which is not represented in this simpe example.
  1456.         
  1457.   In this case the arithmetic code is not completely efficient, which is due 
  1458. to the shortness of the message - with longer messages the coding efficiency 
  1459. does indeed approach 100%.
  1460.  
  1461.   Now that we have an efficient encoding technique, what can we do with it? 
  1462. What we need is a technique for building a model of the data which we can 
  1463. then use with the encoder.  The simplest model is a fixed one, for example a 
  1464. table of standard letter frequencies for English text which we can then use 
  1465. to get letter probabilities.  An improvement on this technique is to use an 
  1466. *adaptive model*, in other words a model which adjusts itself to the data 
  1467. which is being compressed as the data is compressed.  We can convert the 
  1468. fixed model into an adaptive one by adjusting the symbol frequencies after 
  1469. each new symbol is encoded, allowing the model to track the data being 
  1470. transmitted.  However, we can do much better than that.
  1471.  
  1472. Using the symbol probabilities by themselves is not a particularly good
  1473. estimate of the true entropy of the data: We can take into account
  1474. intersymbol probabilities as well.  The best compressors available today
  1475. take this approach: DMC (Dynamic Markov Coding) starts with a zero-order
  1476. Markov model and gradually extends this initial model as compression
  1477. progresses; PPM (Prediction by Partial Matching) looks for a match of the
  1478. text to be compressed in an order-n context.  If no match is found, it
  1479. drops to an order n-1 context, until it reaches order 0.  Both these
  1480. techniques thus obtain a much better model of the data to be compressed,
  1481. which, combined with the use of arithmetic coding, results in superior
  1482. compression performance.
  1483.  
  1484.   So if arithmetic coding-based compressors are so powerful, why are they not 
  1485. used universally?  Apart from the fact that they are relatively new and 
  1486. haven't come into general use too much yet, there is also one major concern:  
  1487. The fact that they consume rather large amounts of computing resources, both 
  1488. in terms of CPU power and memory.  The building of sophisticated models for 
  1489. the compression can chew through a fair amount of memory (especially in the 
  1490. case of DMC, where the model can grow without bounds); and the arithmetic 
  1491. coding itself involves a fair amount of number crunching.
  1492. There is however an alternative approach, a class of compressors generally 
  1493. referred to as *substitutional* or *dictionary-based compressors*.
  1494.  
  1495.  Substitutional Compressors
  1496.  --------------------------
  1497.  
  1498.   The basic idea behind a substitutional compressor is to replace an 
  1499. occurrence of a particular phrase or group of bytes in a piece of data with a 
  1500. reference to a previous occurrence of that phrase.  There are two main 
  1501. classes of schemes, named after Jakob Ziv and Abraham Lempel, who first 
  1502. proposed them in 1977 and 1978.
  1503.  
  1504. <The LZ78 family of compressors>
  1505.  
  1506.   LZ78-based schemes work by entering phrases into a *dictionary* and then, 
  1507. when a repeat occurrence of that particular phrase is found, outputting the 
  1508. dictionary index instead of the phrase.  There exist several compression 
  1509. algorithms based on this principle, differing mainly in the manner in which 
  1510. they manage the dictionary.  The most well-known scheme (in fact the most 
  1511. well-known of all the Lempel-Ziv compressors, the one which is generally (and 
  1512. mistakenly) referred to as "Lempel-Ziv Compression"), is Terry Welch's LZW 
  1513. scheme, which he designed in 1984 for implementation in hardware for high- 
  1514. performance disk controllers.
  1515.  
  1516. Input string: /WED/WE/WEE/WEB
  1517.  
  1518. Character input:    Code output:    New code value and associated string:
  1519.     /W                  /                   256 = /W
  1520.     E                   W                   257 = WE
  1521.     D                   E                   258 = ED
  1522.     /                   D                   259 = D/
  1523.     WE                  256                 260 = /WE
  1524.     /                   E                   261 = E/
  1525.     WEE                 260                 262 = /WEE
  1526.     /W                  261                 263 = E/W
  1527.     EB                  257                 264 = WEB
  1528.     <END>               B
  1529.     
  1530.   LZW starts with a 4K dictionary, of which entries 0-255 refer to individual 
  1531. bytes, and entries 256-4095 refer to substrings.  Each time a new code is 
  1532. generated it means a new string has been parsed.  New strings are generated 
  1533. by appending the current character K to the end of an existing string w.  The 
  1534. algorithm for LZW compression is as follows:
  1535.  
  1536.   set w = NIL
  1537.   loop
  1538.       read a character K
  1539.       if wK exists is in the dictionary
  1540.           w = wK
  1541.       else
  1542.           output the code for w
  1543.           add wK to the string table
  1544.           w = K
  1545.   endloop
  1546.  
  1547.   A sample run of LZW over a (highly redundant) input string can be seen in 
  1548. the diagram above.  The strings are built up character-by-character starting 
  1549. with a code value of 256.  LZW decompression takes the stream of codes and 
  1550. uses it to exactly recreate the original input data.  Just like the 
  1551. compression algorithm, the decompressor adds a new string to the dictionary 
  1552. each time it reads in a new code.  All it needs to do in addition is to 
  1553. translate each incoming code into a string and send it to the output.  A 
  1554. sample run of the LZW decompressor is shown in below.
  1555.  
  1556. Input code: /WED<256>E<260><261><257>B
  1557.  
  1558. Input code:        Output string:     New code value and associated string:
  1559.     /                  /            
  1560.     W                  W                      256 = /W
  1561.     E                  E                      257 = WE
  1562.     D                  D                      258 = ED
  1563.     256                /W                     259 = D/
  1564.     E                  E                      260 = /WE
  1565.     260                /WE                    261 = E/
  1566.     261                E/                     262 = /WEE
  1567.     257                WE                     263 = E/W
  1568.     B                  B                      264 = WEB
  1569.            
  1570.   The most remarkable feature of this type of compression is that the entire 
  1571. dictionary has been transmitted to the decoder without actually explicitly 
  1572. transmitting the dictionary.  At the end of the run, the decoder will have a 
  1573. dictionary identical to the one the encoder has, built up entirely as part of 
  1574. the decoding process.
  1575.     LZW is more commonly encountered today in a variant known as LZC, after 
  1576. its use in the UNIX "compress" program.  In this variant, pointers do not 
  1577. have a fixed length.  Rather, they start with a length of 9 bits, and then 
  1578. slowly grow to their maximum possible length once all the pointers of a 
  1579. particular size have been used up.  Furthermore, the dictionary is not frozen 
  1580. once it is full as for LZW - the program continually monitors compression 
  1581. performance, and once this starts decreasing the entire dictionary is 
  1582. discarded and rebuilt from scratch.  More recent schemes use some sort of 
  1583. least-recently-used algorithm to discard little-used phrases once the 
  1584. dictionary becomes full rather than throwing away the entire dictionary.  
  1585.  
  1586. Finally, not all schemes build up the dictionary by adding a single new 
  1587. character to the end of the current phrase. An alternative technique is to 
  1588. concatenate the previous two phrases (LZMW), which results in a faster 
  1589. buildup of longer phrases than the character-by-character buildup of the 
  1590. other methods.  The disadvantage of this method is that a more sophisticated 
  1591. data structure is needed to handle the dictionary.
  1592.  
  1593. [A good introduction to LZW, MW, AP and Y coding is given in the yabba
  1594. package. For ftp information, see question 2 in part one, file type .Y]
  1595.  
  1596.  
  1597. <The LZ77 family of compressors>
  1598.  
  1599.   LZ77-based schemes keep track of the last n bytes of data seen, and when a 
  1600. phrase is encountered that has already been seen, they output a pair of 
  1601. values corresponding to the position of the phrase in the previously-seen 
  1602. buffer of data, and the length of the phrase.  In effect the compressor moves 
  1603. a fixed-size *window* over the data (generally referred to as a *sliding 
  1604. window*), with the position part of the (position, length) pair referring to 
  1605. the position of the phrase within the window.  The most commonly used 
  1606. algorithms are derived from the LZSS scheme described by James Storer and 
  1607. Thomas Szymanski in 1982.  In this the compressor maintains a window of size 
  1608. N bytes and a *lookahead buffer* the contents of which it tries to find a 
  1609. match for in the window:
  1610.  
  1611.   while( lookAheadBuffer not empty )
  1612.       {
  1613.       get a pointer ( position, match ) to the longest match in the window
  1614.           for the lookahead buffer;
  1615.  
  1616.       if( length > MINIMUM_MATCH_LENGTH )
  1617.           {
  1618.           output a ( position, length ) pair;
  1619.           shift the window length characters along;
  1620.           }
  1621.       else
  1622.           {
  1623.           output the first character in the lookahead buffer;
  1624.           shift the window 1 character along;
  1625.           }
  1626.       }
  1627.         
  1628.   Decompression is simple and fast:  Whenever a ( position, length ) pair is 
  1629. encountered, go to that ( position ) in the window and copy ( length ) bytes 
  1630. to the output.
  1631.  
  1632.   Sliding-window-based schemes can be simplified by numbering the input text
  1633. characters mod N, in effect creating a circular buffer.  The sliding window
  1634. approach automatically creates the LRU effect which must be done explicitly in
  1635. LZ78 schemes.  Variants of this method apply additional compression to the
  1636. output of the LZSS compressor, which include a simple variable-length code
  1637. (LZB), dynamic Huffman coding (LZH), and Shannon-Fano coding (ZIP 1.x)), all
  1638. of which result in a certain degree of improvement over the basic scheme,
  1639. especially when the data are rather random and the LZSS compressor has little
  1640. effect.
  1641.   Recently an algorithm was developed which combines the ideas behind LZ77 and
  1642. LZ78 to produce a hybrid called LZFG.  LZFG uses the standard sliding window,
  1643. but stores the data in a modified trie data structure and produces as output
  1644. the position of the text in the trie.  Since LZFG only inserts complete
  1645. *phrases* into the dictionary, it should run faster than other LZ77-based
  1646. compressors.
  1647.  
  1648. All popular archivers (arj, lha, zip, zoo) are variations on the LZ77 theme.
  1649.  
  1650. ------------------------------------------------------------------------------
  1651.  
  1652. ~Subject: [71] Introduction to MPEG (long)
  1653.  
  1654.  
  1655. Written by Mark Adler <madler@cco.caltech.edu>.
  1656.  
  1657. Q. What is MPEG?
  1658. A. MPEG is a group of people that meet under ISO (the International
  1659.    Standards Organization) to generate standards for digital video
  1660.    (sequences of images in time) and audio compression.  In particular,
  1661.    they define a compressed bit stream, which implicitly defines a
  1662.    decompressor.  However, the compression algorithms are up to the
  1663.    individual manufacturers, and that is where proprietary advantage
  1664.    is obtained within the scope of a publicly available international
  1665.    standard.  MPEG meets roughly four times a year for roughly a week
  1666.    each time.  In between meetings, a great deal of work is done by
  1667.    the members, so it doesn't all happen at the meetings.  The work
  1668.    is organized and planned at the meetings.
  1669.  
  1670. Q. So what does MPEG stand for?
  1671. A. Moving Pictures Experts Group.
  1672.  
  1673. Q. Does it have anything to do with JPEG?
  1674. A. Well, it sounds the same, and they are part of the same subcommittee
  1675.    of ISO along with JBIG and MHEG, and they usually meet at the same
  1676.    place at the same time.  However, they are different sets of people
  1677.    with few or no common individual members, and they have different
  1678.    charters and requirements.  JPEG is for still image compression.
  1679.  
  1680. Q. Then what's JBIG and MHEG?
  1681. A. Sorry I mentioned them. Ok, I'll simply say that JBIG is for binary
  1682.    image compression (like faxes), and MHEG is for multi-media data
  1683.    standards (like integrating stills, video, audio, text, etc.).
  1684.    For an introduction to JBIG, see question 54 below.
  1685.  
  1686. Q. Ok, I'll stick to MPEG.  What has MPEG accomplished?
  1687. A. So far (as of January 1992), they have completed the "Committee
  1688.    Draft" of MPEG phase I, colloquially called MPEG I.  It defines
  1689.    a bit stream for compressed video and audio optimized to fit into
  1690.    a bandwidth (data rate) of 1.5 Mbits/s.  This rate is special
  1691.    because it is the data rate of (uncompressed) audio CD's and DAT's.
  1692.    The draft is in three parts, video, audio, and systems, where the
  1693.    last part gives the integration of the audio and video streams
  1694.    with the proper timestamping to allow synchronization of the two.
  1695.    They have also gotten well into MPEG phase II, whose task is to
  1696.    define a bitstream for video and audio coded at around 3 to 10
  1697.    Mbits/s.
  1698.  
  1699. Q. So how does MPEG I work?
  1700. A. First off, it starts with a relatively low resolution video
  1701.    sequence (possibly decimated from the original) of about 352 by
  1702.    240 frames by 30 frames/s (US--different numbers for Europe),
  1703.    but original high (CD) quality audio.  The images are in color,
  1704.    but converted to YUV space, and the two chrominance channels
  1705.    (U and V) are decimated further to 176 by 120 pixels.  It turns
  1706.    out that you can get away with a lot less resolution in those
  1707.    channels and not notice it, at least in "natural" (not computer
  1708.    generated) images.
  1709.  
  1710.    The basic scheme is to predict motion from frame to frame in the
  1711.    temporal direction, and then to use DCT's (discrete cosine
  1712.    transforms) to organize the redundancy in the spatial directions.
  1713.    The DCT's are done on 8x8 blocks, and the motion prediction is
  1714.    done in the luminance (Y) channel on 16x16 blocks.  In other words,
  1715.    given the 16x16 block in the current frame that you are trying to
  1716.    code, you look for a close match to that block in a previous or
  1717.    future frame (there are backward prediction modes where later
  1718.    frames are sent first to allow interpolating between frames).
  1719.    The DCT coefficients (of either the actual data, or the difference
  1720.    between this block and the close match) are "quantized", which
  1721.    means that you divide them by some value to drop bits off the
  1722.    bottom end.  Hopefully, many of the coefficients will then end up
  1723.    being zero.  The quantization can change for every "macroblock"
  1724.    (a macroblock is 16x16 of Y and the corresponding 8x8's in both
  1725.    U and V).  The results of all of this, which include the DCT
  1726.    coefficients, the motion vectors, and the quantization parameters
  1727.    (and other stuff) is Huffman coded using fixed tables.  The DCT
  1728.    coefficients have a special Huffman table that is "two-dimensional"
  1729.    in that one code specifies a run-length of zeros and the non-zero
  1730.    value that ended the run.  Also, the motion vectors and the DC
  1731.    DCT components are DPCM (subtracted from the last one) coded.
  1732.  
  1733. Q. So is each frame predicted from the last frame?
  1734. A. No.  The scheme is a little more complicated than that.  There are
  1735.    three types of coded frames.  There are "I" or intra frames.  They
  1736.    are simply a frame coded as a still image, not using any past
  1737.    history.  You have to start somewhere.  Then there are "P" or
  1738.    predicted frames.  They are predicted from the most recently
  1739.    reconstructed I or P frame.  (I'm describing this from the point
  1740.    of view of the decompressor.)  Each macroblock in a P frame can
  1741.    either come with a vector and difference DCT coefficients for a
  1742.    close match in the last I or P, or it can just be "intra" coded
  1743.    (like in the I frames) if there was no good match.
  1744.  
  1745.    Lastly, there are "B" or bidirectional frames.  They are predicted
  1746.    from the closest two I or P frames, one in the past and one in the
  1747.    future.  You search for matching blocks in those frames, and try
  1748.    three different things to see which works best.  (Now I have the
  1749.    point of view of the compressor, just to confuse you.)  You try using
  1750.    the forward vector, the backward vector, and you try averaging the
  1751.    two blocks from the future and past frames, and subtracting that from
  1752.    the block being coded.  If none of those work well, you can intra-
  1753.    code the block.
  1754.  
  1755.    The sequence of decoded frames usually goes like:
  1756.  
  1757.    IBBPBBPBBPBBIBBPBBPB...
  1758.  
  1759.    Where there are 12 frames from I to I (for US and Japan anyway.)
  1760.    This is based on a random access requirement that you need a
  1761.    starting point at least once every 0.4 seconds or so.  The ratio
  1762.    of P's to B's is based on experience.
  1763.  
  1764.    Of course, for the decoder to work, you have to send that first
  1765.    P *before* the first two B's, so the compressed data stream ends
  1766.    up looking like:
  1767.  
  1768.    0xx312645...
  1769.  
  1770.    where those are frame numbers.  xx might be nothing (if this is
  1771.    the true starting point), or it might be the B's of frames -2 and
  1772.    -1 if we're in the middle of the stream somewhere.
  1773.  
  1774.    You have to decode the I, then decode the P, keep both of those
  1775.    in memory, and then decode the two B's.  You probably display the
  1776.    I while you're decoding the P, and display the B's as you're
  1777.    decoding them, and then display the P as you're decoding the next
  1778.    P, and so on.
  1779.  
  1780. Q. You've got to be kidding.
  1781. A. No, really!
  1782.  
  1783. Q. Hmm.  Where did they get 352x240?
  1784. A. That derives from the CCIR-601 digital television standard which
  1785.    is used by professional digital video equipment.  It is (in the US)
  1786.    720 by 243 by 60 fields (not frames) per second, where the fields
  1787.    are interlaced when displayed.  (It is important to note though
  1788.    that fields are actually acquired and displayed a 60th of a second
  1789.    apart.)  The chrominance channels are 360 by 243 by 60 fields a
  1790.    second, again interlaced.  This degree of chrominance decimation
  1791.    (2:1 in the horizontal direction) is called 4:2:2.  The source
  1792.    input format for MPEG I, called SIF, is CCIR-601 decimated by 2:1
  1793.    in the horizontal direction, 2:1 in the time direction, and an
  1794.    additional 2:1 in the chrominance vertical direction.  And some
  1795.    lines are cut off to make sure things divide by 8 or 16 where
  1796.    needed.
  1797.  
  1798. Q. What if I'm in Europe?
  1799. A. For 50 Hz display standards (PAL, SECAM) change the number of lines
  1800.    in a field from 243 or 240 to 288, and change the display rate to
  1801.    50 fields/s or 25 frames/s.  Similarly, change the 120 lines in
  1802.    the decimated chrominance channels to 144 lines.  Since 288*50 is
  1803.    exactly equal to 240*60, the two formats have the same source data
  1804.    rate.
  1805.  
  1806. Q. You didn't mention anything about the audio compression.
  1807. A. Oh, right.  Well, I don't know as much about the audio compression.
  1808.    Basically they use very carefully developed psychoacoustic models
  1809.    derived from experiments with the best obtainable listeners to
  1810.    pick out pieces of the sound that you can't hear.  There are what
  1811.    are called "masking" effects where, for example, a large component
  1812.    at one frequency will prevent you from hearing lower energy parts
  1813.    at nearby frequencies, where the relative energy vs. frequency
  1814.    that is masked is described by some empirical curve.  There are
  1815.    similar temporal masking effects, as well as some more complicated
  1816.    interactions where a temporal effect can unmask a frequency, and
  1817.    vice-versa.
  1818.  
  1819.    The sound is broken up into spectral chunks with a hybrid scheme
  1820.    that combines sine transforms with subband transforms, and the
  1821.    psychoacoustic model written in terms of those chunks.  Whatever
  1822.    can be removed or reduced in precision is, and the remainder is
  1823.    sent.  It's a little more complicated than that, since the bits
  1824.    have to be allocated across the bands.  And, of course, what is
  1825.    sent is entropy coded.
  1826.  
  1827. Q. So how much does it compress?
  1828. A. As I mentioned before, audio CD data rates are about 1.5 Mbits/s.
  1829.    You can compress the same stereo program down to 256 Kbits/s with
  1830.    no loss in discernable quality.  (So they say.  For the most part
  1831.    it's true, but every once in a while a weird thing might happen
  1832.    that you'll notice.  However the effect is very small, and it takes
  1833.    a listener trained to notice these particular types of effects.)
  1834.    That's about 6:1 compression.  So, a CD MPEG I stream would have
  1835.    about 1.25 MBits/s left for video.  The number I usually see though
  1836.    is 1.15 MBits/s (maybe you need the rest for the system data
  1837.    stream).  You can then calculate the video compression ratio from
  1838.    the numbers here to be about 26:1.  If you step back and think
  1839.    about that, it's little short of a miracle.  Of course, it's lossy
  1840.    compression, but it can be pretty hard sometimes to see the loss,
  1841.    if you're comparing the SIF original to the SIF decompressed.  There
  1842.    is, however, a very noticeable loss if you're coming from CCIR-601
  1843.    and have to decimate to SIF, but that's another matter.  I'm not
  1844.    counting that in the 26:1.
  1845.  
  1846.    The standard also provides for other bit rates ranging from 32Kbits/s
  1847.    for a single channel, up to 448 Kbits/s for stereo.
  1848.  
  1849. Q. What's phase II?
  1850. A. As I said, there is a considerable loss of quality in going from
  1851.    CCIR-601 to SIF resolution.  For entertainment video, it's simply
  1852.    not acceptable.  You want to use more bits and code all or almost
  1853.    all the CCIR-601 data.  From subjective testing at the Japan
  1854.    meeting in November 1991, it seems that 4 MBits/s can give very
  1855.    good quality compared to the original CCIR-601 material.  The
  1856.    objective of phase II is to define a bit stream optimized for these
  1857.    resolutions and bit rates.
  1858.  
  1859. Q. Why not just scale up what you're doing with MPEG I?
  1860. A. The main difficulty is the interlacing.  The simplest way to extend
  1861.    MPEG I to interlaced material is to put the fields together into
  1862.    frames (720x486x30/s).  This results in bad motion artifacts that
  1863.    stem from the fact that moving objects are in different places
  1864.    in the two fields, and so don't line up in the frames.  Compressing
  1865.    and decompressing without taking that into account somehow tends to
  1866.    muddle the objects in the two different fields.
  1867.  
  1868.    The other thing you might try is to code the even and odd field
  1869.    streams separately.  This avoids the motion artifacts, but as you
  1870.    might imagine, doesn't get very good compression since you are not
  1871.    using the redundancy between the even and odd fields where there
  1872.    is not much motion (which is typically most of image).
  1873.  
  1874.    Or you can code it as a single stream of fields.  Or you can
  1875.    interpolate lines.  Or, etc. etc.  There are many things you can
  1876.    try, and the point of MPEG II is to figure out what works well.
  1877.    MPEG II is not limited to consider only derivations of MPEG I.
  1878.    There were several non-MPEG I-like schemes in the competition in
  1879.    November, and some aspects of those algorithms may or may not
  1880.    make it into the final standard for entertainment video compression.
  1881.  
  1882. Q. So what works?
  1883. A. Basically, derivations of MPEG I worked quite well, with one that
  1884.    used wavelet subband coding instead of DCT's that also worked very
  1885.    well.  Also among the worked-very-well's was a scheme that did not
  1886.    use B frames at all, just I and P's.  All of them, except maybe one,
  1887.    did some sort of adaptive frame/field coding, where a decision is
  1888.    made on a macroblock basis as to whether to code that one as one
  1889.    frame macroblock or as two field macroblocks.  Some other aspects
  1890.    are how to code I-frames--some suggest predicting the even field
  1891.    from the odd field.  Or you can predict evens from evens and odds
  1892.    or odds from evens and odds or any field from any other field, etc.
  1893.  
  1894. Q. So what works?
  1895. A. Ok, we're not really sure what works best yet.  The next step is
  1896.    to define a "test model" to start from, that incorporates most of
  1897.    the salient features of the worked-very-well proposals in a
  1898.    simple way.  Then experiments will be done on that test model,
  1899.    making a mod at a time, and seeing what makes it better and what
  1900.    makes it worse.  Example experiments are, B's or no B's, DCT vs.
  1901.    wavelets, various field prediction modes, etc.  The requirements,
  1902.    such as implementation cost, quality, random access, etc. will all
  1903.    feed into this process as well.
  1904.  
  1905. Q. When will all this be finished?
  1906. A. I don't know.  I'd have to hope in about a year or less.
  1907.  
  1908. Q. How do I join MPEG?
  1909. A. You don't join MPEG.  You have to participate in ISO as part of a
  1910.    national delegation.  How you get to be part of the national
  1911.    delegation is up to each nation.  I only know the U.S., where you
  1912.    have to attend the corresponding ANSI meetings to be able to
  1913.    attend the ISO meetings.  Your company or institution has to be
  1914.    willing to sink some bucks into travel since, naturally, these
  1915.    meetings are held all over the world.  (For example, Paris,
  1916.    Santa Clara, Kurihama Japan, Singapore, Haifa Israel, Rio de
  1917.    Janeiro, London, etc.)
  1918.  
  1919. Q. Well, then how do I get the documents, like the MPEG I draft?
  1920. A. If you aren't part of the process, then you have to try to get
  1921.    them from your national body, which is ANSI in the U.S.  ANSI
  1922.    won't have any stuff (I don't think) pertaining to MPEG II, but
  1923.    they should have the MPEG I Committee Draft, since it is now up
  1924.    for balloting in the U.S. (as well as the other countries).  It
  1925.    has all the nitty gritty details about the systems, video, and
  1926.    audio data streams and informative annexes about how to really
  1927.    do it.
  1928.  
  1929. ------------------------------------------------------------------------------
  1930.  
  1931. ~Subject: [72] What is wavelet theory?
  1932.  
  1933.  
  1934. Preprints and software are available by anonymous ftp from the
  1935. Yale Mathematics Department computer ceres.math.yale.edu[130.132.23.22],
  1936. in pub/wavelets and pub/software.
  1937.  
  1938. epic is pyramid wavelet coder. (For source code, see question 3 in part one).
  1939.  
  1940. Bill Press of Harvard/CfA has made some things available for anonymous
  1941. ftp on cfata4.harvard.edu [128.103.40.79] in directory /pub. There is
  1942. a short TeX article on wavelet theory (wavelet.tex, to be included in
  1943. a future edition of Numerical Recipes), some sample wavelet code
  1944. (wavelet.f, in FORTRAN - sigh), and a beta version of an astronomical
  1945. image compression program which he is currently developing (FITS
  1946. format data files only, in fitspress08.tar.Z).
  1947.  
  1948.  
  1949. A 5 minute course in wavelet transforms, by Richard Kirk <rak@crosfield.co.uk>:
  1950.  
  1951. Do you know what a Haar transform is? Its a transform to another orthonormal
  1952. space (like the DFT), but the basis functions are a set of square wave bursts
  1953. like this...
  1954.  
  1955.    +--+                         +------+
  1956.    +  |  +------------------    +      |      +--------------
  1957.       +--+                             +------+
  1958.  
  1959.          +--+                                 +------+
  1960.    ------+  |  +------------    --------------+      |      +
  1961.             +--+                                     +------+
  1962.  
  1963.                +--+             +-------------+
  1964.    ------------+  |  +------    +             |             +
  1965.                   +--+                        +-------------+
  1966.  
  1967.                      +--+       +---------------------------+
  1968.    ------------------+  |  +    +                           +
  1969.                         +--+
  1970.  
  1971. This is the set of functions for an 8-element 1-D Haar transform. You
  1972. can probably see how to extend this to higher orders and higher dimensions
  1973. yourself. This is dead easy to calculate, but it is not what is usually
  1974. understood by a wavelet transform.
  1975.  
  1976. If you look at the eight Haar functions you see we have four functions
  1977. that code the highest resolution detail, two functions that code the
  1978. coarser detail, one function that codes the coarser detail still, and the 
  1979. top function that codes the average value for the whole `image'.
  1980.  
  1981. Haar function can be used to code images instead of the DFT. With bilevel
  1982. images (such as text) the result can look better, and it is quicker to code.
  1983. Flattish regions, textures, and soft edges in scanned images get a nasty
  1984. `blocking' feel to them. This is obvious on hardcopy, but can be disguised on
  1985. color CRTs by the effects of the shadow mask. The DCT gives more consistent
  1986. results.
  1987.  
  1988. This connects up with another bit of maths sometimes called Multispectral
  1989. Image Analysis, sometimes called Image Pyramids.
  1990.  
  1991. Suppose you want to produce a discretely sampled image from a continuous 
  1992. function. You would do this by effectively `scanning' the function using a
  1993. sinc function [ sin(x)/x ] `aperture'. This was proved by Shannon in the 
  1994. `forties. You can do the same thing starting with a high resolution
  1995. discretely sampled image. You can then get a whole set of images showing 
  1996. the edges at different resolutions by differencing the image at one
  1997. resolution with another version at another resolution. If you have made this
  1998. set of images properly they ought to all add together to give the original 
  1999. image.
  2000.  
  2001. This is an expansion of data. Suppose you started off with a 1K*1K image.
  2002. You now may have a 64*64 low resolution image plus difference images at 128*128
  2003. 256*256, 512*512 and 1K*1K. 
  2004.  
  2005. Where has this extra data come from? If you look at the difference images you 
  2006. will see there is obviously some redundancy as most of the values are near 
  2007. zero. From the way we constructed the levels we know that locally the average
  2008. must approach zero in all levels but the top. We could then construct a set of
  2009. functions out of the sync functions at any level so that their total value 
  2010. at all higher levels is zero. This gives us an orthonormal set of basis 
  2011. functions for a transform. The transform resembles the Haar transform a bit,
  2012. but has symmetric wave pulses that decay away continuously in either direction
  2013. rather than square waves that cut off sharply. This transform is the
  2014. wavelet transform ( got to the point at last!! ).
  2015.  
  2016. These wavelet functions have been likened to the edge detecting functions
  2017. believed to be present in the human retina.
  2018.  
  2019. The basis functions of the wavelet transform are harder to calculate, and there
  2020. is at present no fast wavelet transform to rival the fast DCT algorithms. Or
  2021. if there is I would like to know about it. 
  2022.  
  2023. For image compression we usually use an 8*8 DCT rather than transform the whole
  2024. image. You could do an 8*8 wavelet transform. This could run as fast as the 8*8
  2025. DCT in many of the current hardwares, but what would this give you? The results
  2026. look much the same as the FFT.
  2027.  
  2028. ------------------------------------------------------------------------------
  2029.  
  2030. ~Subject: [73] What is the theoretical compression limit?
  2031.  
  2032.  
  2033. There is no compressor that is guaranteed to compress all possible input
  2034. files. If it compresses some files, then it must enlarge some others.
  2035. This can be proven by a simple counting argument (see question 9).
  2036.  
  2037. As an extreme example, the following algorithm achieves 100%
  2038. compression for one special input file and enlarges all other files by
  2039. only one bit:
  2040.  
  2041. - if the input data is <insert your favorite one here>, output an empty file.
  2042. - otherwise output one bit (zero or one) followed by the input data.
  2043.  
  2044. The concept of theoretical compression limit is meaningful only
  2045. if you have a model for your input data. See question 70 above
  2046. for some examples of data models.
  2047.  
  2048. ------------------------------------------------------------------------------
  2049.  
  2050. ~Subject: [74] Introduction to JBIG
  2051.  
  2052.  
  2053. Written by Mark Adler <madler@cco.caltech.edu>.
  2054.  
  2055. JBIG losslessly compresses binary (one-bit/pixel) images.  (The B stands
  2056. for bi-level.)  Basically it models the redundancy in the image as the
  2057. correlations of the pixel currently being coded with a set of nearby
  2058. pixels called the template.  An example template might be the two
  2059. pixels preceding this one on the same line, and the five pixels centered
  2060. above this pixel on the previous line.  Note that this choice only
  2061. involves pixels that have already been seen from a scanner.
  2062.  
  2063. The current pixel is then arithmetically coded based on the eight-bit
  2064. (including the pixel being coded) state so formed.  So there are (in this
  2065. case) 256 contexts to be coded.  The arithmetic coder and probability
  2066. estimator for the contexts are actually IBM's (patented) Q-coder.  The
  2067. Q-coder uses low precision, rapidly adaptable (those two are related)
  2068. probability estimation combined with a multiply-less arithmetic coder.
  2069. The probability estimation is intimately tied to the interval calculations
  2070. necessary for the arithmetic coding.
  2071.  
  2072. JBIG actually goes beyond this and has adaptive templates, and probably
  2073. some other bells and whistles I don't know about.  You can find a
  2074. description of the Q-coder as well as the ancestor of JBIG in the Nov 88
  2075. issue of the IBM Journal of Research and Development.  This is a very
  2076. complete and well written set of five articles that describe the Q-coder
  2077. and a bi-level image coder that uses the Q-coder.
  2078.  
  2079. You can use JBIG on grey-scale or even color images by simply applying
  2080. the algorithm one bit-plane at a time.  You would want to recode the
  2081. grey or color levels first though, so that adjacent levels differ in
  2082. only one bit (called Gray-coding).  I hear that this works well up to
  2083. about six bits per pixel, beyond which JPEG's lossless mode works better.
  2084. You need to use the Q-coder with JPEG also to get this performance.
  2085.  
  2086. Actually no lossless mode works well beyond six bits per pixel, since
  2087. those low bits tend to be noise, which doesn't compress at all.
  2088.  
  2089. Anyway, the intent of JBIG is to replace the current, less effective
  2090. group 3 and 4 fax algorithms.
  2091.  
  2092. ------------------------------------------------------------------------------
  2093.  
  2094. ~Subject: [99] Acknowledgments
  2095.  
  2096.  
  2097. There are too many people to cite. Thanks to all people who directly
  2098. or indirectly contributed to this FAQ.
  2099.  
  2100.